Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you always want to the application to launch into the same UIViewController you need to set the RootViewController of your application. You can do this in the Interface Builder by ticking the box that says "Is Initial View Controller"</p> <p><img src="https://i.stack.imgur.com/lCWC4.png" alt="enter image description here"> </p> <p>or in your <code>(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions</code> method you can set the rootViewController as</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //... self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"MyLoginViewControllerStoryboardID"]; return YES; } </code></pre> <p>Note that you then have to set the storyboard ID properly in the Interface Builder. That is</p> <p><img src="https://i.stack.imgur.com/DUToZ.png" alt="enter image description here"></p> <p>Also, on a side note, if you want to show the <em>LoginViewController</em> <strong>only</strong> if the user is currently <strong>not</strong> logged in you can do something a like this</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL isLoggedIn = [[NSUserDefaults standardDefaults] boolForKey:@"IsLoggedIn"]; NSString *rootStoryboardID; if(isLoggedIn) { rootStoryboardID = @"LoginViewControllerStoryboardID"; } else { rootStoryboardID = @"MainViewControllerStoryboardID"; } self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:rootStoryboardID]; return YES; } </code></pre> <p>Hope it helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload