ioswalkthroughapplication-structure

Showing/dismissing a walkthrough - iOS Application structure


I need to present the classic walkthrough when the Application get launched the first time but, with the implementation that I have in mind, I end up with a structure that keeps the walkthrough as first controller of the hierarchy... and I don't like that. Here is a description of my implementation:

1) In the didFinishLaunchingWithOption I check UsereDefault to catch the first launch

2) If is the first launch I substitute the rootViewController of the window with the walkthrough

3) When the walkthrough is finished I present the first view controller of the App

The problem is with point 3. Presenting the controller from the walkthrough I end up with the whole application presente as modal of the walkthrough... what I want is to completely substitute the walkthrough with the standard first view controller.

Could you suggest a good pattern to show/dismiss a walkthrough?


Solution

  • When you finish Walk-through, replace the rootViewController of your window.

    FirstViewController *firstVC = [[FirstViewController alloc] init];
    yourAppDelegate.window.rootViewController = firstVC;
    

    Or if you are using storyboard:

    FirstViewController *firstVC = (FirstViewController *)[[UIStoryboard storyboardWithName:@"YourStoryboardName" bundle: nil] instantiateViewControllerWithIdentifier:@"YourFirstVCId"];
    yourAppDelegate.window.rootViewController = firstVC;
    

    Another option is Show the Walkthrough as modal on top of FirstViewController if it's first time.