简体   繁体   中英

About tab bar using storyboard

I want to create an app using storyboard that has login window and tab bar controller.

So the flow will be upon tapping the login button, the app will be redirected to tab bar controller with its views.

I have done this: 在此处输入图片说明

But referring to Apple Documentation: UITabBarController

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

So that means I am not allowed to do so?

In addition: The 3 views that are referred by my tab bar, then each of them has their own child view again, but the tab bar in the child view is gone. What could be happen? Am I missing something?

What I have done in all my apps that are structured similarly is to have the first view controller check for valid authentication and if that fails, present a login VC. That login VC has a delegate defined that will pass back the user credential after a successful login and then dismisses the modal login VC does whatever.

Here is a sample layout: 布局

The delegate protocol looks like this:

@protocol LoginViewControllerDelegate
    -(void)finishedLoadingUserInfo:(UserInfo *)curUser;
@end

Where UserInfo is the model I use for the user information (in my case, NetworkID, FullName, etc).

When the user has successfully authenticated, I fire off that delegate method which is handled in the class that presented it. If you need more detail, I can help - but the process is simple.

You can launch your login screen first from the appDelegate and then setup and launch the tabBarViewController after the login is successful.

An alternative design is to do the following steps: 1. set up your tabBarViewController, 2. disable the tabs, 3. launch your login view controller modally, 4. enable tabViewController tabs

Either of these two approaches should work.

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