简体   繁体   中英

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?

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.

看一下该库以实现您的演练https://github.com/ruipfcosta/SwiftyWalkthrough

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM