问题
I have an application with a UITabBarController at its top level. I track which tab a user is on and store it so that when they reopen the application they are on the tab they were on when it was closed. So there is no default tab when the app starts up.
I have a modal screen that shows first every time the app starts. It doesn't matter which tab was saved, the user is always presented with this view.
Where should this modal view be presented from? The logical thing would be to have the UITabBarController present it as it is the rootViewController, but Apple discourages subclassing UITabBarController. Another approach would be to have a UIViewController as the rootViewController that would handle the presentation, but Apple insist that UITabBarController should be the rootViewController.
So how should I deal with this?
回答1:
If you start with a window-based application and first set your viewController
as rootViewController
and then, after you're done with this viewController
, set the tabBarController
as rootViewController
, i think you don't have problems.
来源:https://stackoverflow.com/questions/10537881/where-should-i-present-modal-view-controller