Tuesday, October 24, 2017

Launch iOS app without using Storyboard



1. Create your own ViewController in your application
2. Add @property (strong, nonatomic) UINavigationController *navController in your AppDelegate.h
3. Add the following codes inside 'didFinishLaunchingWithOptions'
   UIViewController *viewController = [[YourVC alloc] init];
OR 
   [[NSClassFromString(@"YourVC") alloc] initWithNibName:@"YourVC" bundle:nil];


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    
    self.navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    self.navController.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    [self.window setRootViewController:self.navController];
    
    [UIApplication sharedApplication].statusBarHidden = YES; // If needed
    [self.window makeKeyAndVisible];
    return YES;