Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're not really providing enough information to properly answer the question. The answer could depend on:</p> <ul> <li>Are you using storyboards?</li> <li>Xib file?</li> <li>All in code?</li> </ul> <p>For the sake of argument, let's say you are not using storyboards and you've somehow constructed a view controller in your app delegate.</p> <p>You could check your first run status there and do as Prasad suggested: (Assuming you refactor your first run check into a separate method in app delegate) ...in didFinishLaunchingWithOptions:</p> <pre><code>self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIViewController* controller; if([self isFirstRun]) { controller = [[MyFirstRunController alloc] init]; } else { controller = [[MyStandardController alloc] init]; } [[self window] setRootViewController:controller]; [self.window makeKeyAndVisible]; </code></pre> <p>....</p> <p>That's one way. Another option, UIViewController provides a loadView method specifically for creating your controllers' view. So another approach would be to just create your standard view controller in app delegate and then do your first run check inside that controllers loadView override. And then set the appropriate view there. </p> <p>It really depends on what your first run view does and whether it needs its own controller or can be managed by your standard controller. Only you know that.</p> <p>If you go this latter route, you would do like this your standard controller:</p> <pre><code>-(void)loadView { UIView *rootView; CGRect frame = [[UIScreen mainScreen] bounds]; if([self isFirstRun]) { rootView = [[MyFirstRunView alloc] initWithFrame:frame]; } else { rootView = [[MyStandardView alloc] initWithFrame:frame]; } [self setView:rootView]; } </code></pre> <p>Update</p> <p>If loading from a storyboard, your best bet would be to keep your 'default' controller as is and check your first run status before the view loads, perhaps in viewWillAppear - and then load your storyboard based view controller manually from the storyboard and present in modally. Something like:</p> <pre><code>- (void)presentFirstRunViewController { UIStoryboard *storyboard = self.storyboard; FirstRunViewController *controller = [storyboard instantiateControllerWithIdentifier:@"FirstRunController"]; // Configure the new controller [self presentViewController:controller animated:YES completion:nil]; } </code></pre> <p>In general, the first approach (two controllers) is preferred because its a cleaner separation of responsibility. But it really depends on your needs.</p> <p>Please confirm the code - typed on a Windows machine (vs pasted from XCode)...</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