开发者

How to recreate a UIViewController stack when the root view controller is a UITabBarController?

I have an app that if it is quit in a certain view, I want to restore this view exactly where the user left.

My applicationDidFinishLaunching is very simple at the moment:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    // Override point for customization after app launch    
    [window addSubview:tabBarController.view];
 [window makeKeyAndVisible];

}

What can I do to restore a sequence of 3 view controllers that must be stacked in the tab bar controller?

Normally, the user do these interactions with the app to go in the view that I want to restore:

  1. App pops out;
  2. The first tab is a table view (so its the first view controller that I have to restore) and user selects a row;
  3. The view that appears is another table view (so its the second view controller that I have to restore) and user taps a + in the top bar of this view;
  4. The last view controller appears in a modal way (so its the third view controller that I have to restore).

I t开发者_如何学Goried what the answer of this post suggests, but my tab bar controller turns out in a mess (the post don't use a tab bar controller and I'm a beginner in iPhone development, so my tries wasn't very successful).

Thanks in advance.


It doesn't sound like you're describing typical UITabBarController use patterns, where you have a series of tabs that are always available and offer different modes of use for the application. Usually recreating the state of a tab bar controller is just a matter of instantiating the tabs as usual and selecting the current tab.

A sequence of screens that provide increasing levels of detail is the normal use pattern for UINavigationController.

You may want to investigate whether you have a sane design before worrying about how to restore it.

That said, you can either recreate your whole structure in applicationDidFinishLaunching, or you can give each class the logic to recreate the view controllers and views that are downstream. I would take the latter approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜