Im looking for a way to change the starting view within the storyboard. I have 2 different views, one for a tutorial and the other one is the app itself. I want to load the tutorial the first time the app is loaded and next time it should just be the app itself. How can I do this with code?
-
what have you tried? A quick Google search has given me a few answers already. [try this previous question](http://stackoverflow.com/questions/8451975/conditionally-start-at-different-places-in-storyboard-from-appdelegate) but skip to the Oct '12 answer. – Dan Jul 01 '13 at 13:16
4 Answers
Are you trying to do it from a nibfile or in the AppDelegate?
In the first case, just check the flag "Is Initial View Controller".
in the second you must put your controller as RootViewController, like this:
- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)options{
UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
MenuViewController *menu = [navController.storyboard instantiateViewControllerWithIdentifier:@"MenuController"];
CustomViewController *custom = [navController.storyboard instantiateViewControllerWithIdentifier:@"CustomController"];
// First item in array is bottom of stack, last item is top.
navController.viewControllers = [NSArray arrayWithObjects:menu, custom, nil];
[self.window makeKeyAndVisible];
return YES;
}

- 447
- 5
- 18
Check these links fir first time app launch First iPhone Launch and First Launch
When u find app is launching first time load or push ur tutorial ViewController else load your default View controller as per ur need.

- 1
- 1

- 2,302
- 1
- 16
- 35
A way to do it with less code is to create a third view controller, call it root view, which will always be the first to load, then inside this view you check
which view to load next, either the tutorial or the app view.
Give each view a storyboard ID
call the tutorial view: @"tutorialMainView"
and the app view: @"appMainView"
Then from within the root view you can load it as follows:
NSString *viewName = @"tutorialMainView";
UIViewController *tempView = [[UIStoryboard storyboardWithName:@"my_storyboard" bundle:nil] instantiateViewControllerWithIdentifier:viewName];
It's up to you what to do afterwards, either push it, or have it replace the current rootView (I recommend setting it as the new rootViewController)

- 3,211
- 22
- 36
1.Go to storyboard
2.click on th view you want to make first
look at this picture and set initial controller as it is in image

- 6,556
- 2
- 25
- 31