简体   繁体   English

关于使用情节提要的选项卡栏

[英]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 但请参阅Apple文档:UITabBarController

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. 因为UITabBarController类继承自UIViewController类,所以选项卡栏控制器具有自己的视图,可通过view属性访问该视图。 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. 另外:我的选项卡栏引用的3个视图,然后每个视图又有自己的子视图,但是子视图中的选项卡栏消失了。 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. 我在所有结构相似的应用程序中所做的工作是,让第一个视图控制器检查有效的身份验证,如果失败,则显示登录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. 该登录VC具有定义的委托,该委托将在成功登录后传回用户凭据,然后关闭模式登录VC会执行任何操作。

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). 其中UserInfo是我用于用户信息的模型(在本例中为NetworkID,FullName等)。

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. 您可以先从appDelegate启动登录屏幕,然后在登录成功后设置并启动tabBarViewController。

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 一种替代设计是执行以下步骤:1.设置tabBarViewController,2.禁用选项卡,3.模态启动登录视图控制器,4.启用tabViewController选项卡

Either of these two approaches should work. 这两种方法均应起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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