login page and navigation bar

2019-06-06 14:41发布

问题:

When first launching the apps, I want it to show a button to log in. After successfully logged in, I want the app to show a tab bar view.. So does this mean that I need to set my app delegate to point to the UITabBarController? How can I do this?

回答1:

I load my UITabBarController in the app delegate, so before adding the login screen the last bit of the applicationDidFinishLaunchingWithOptions looks like this:

[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];

To add a view that covers the tabbar you simply insert it after the tabbarcontroller and before the makeKeyAndVisible, like this:

[window addSubview:tabcontroller.view];
[window addSubview:loginViewController.view];
[window makeKeyAndVisible];

The "loginViewController" view will appear covering everything. Once you dismiss it the tab bar will be visible and usable.