简体   繁体   English

选择到标签栏控制器

[英]Segue to Tab Bar Controller

I have this problem: 我有这个问题:

I have an app that has 2 parts, the first part is when it's the first time the user opens the app, a screen with "whats your name" appears and he follows to a screen that has some buttons and it ends in a tableview where he can press a button in the footer to go to the other part of the app that is a view controller with 2 buttons: 1 - Go back to that first button screen (after whats your name), 2 - Go to tab bar controller. 我有一个包含两部分的应用程序,第一部分是用户首次打开该应用程序时,出现“您的名字是什么”屏幕,然后他进入具有一些按钮的屏幕,并在表格视图中结束他可以按页脚中的按钮以转到应用程序的另一部分,该应用程序是具有2个按钮的视图控制器:1-返回第一个按钮屏幕(以您的名字命名),2-转到标签栏控制器。 My problem is: when I segue to the tab bar controller 2 navigation bar's appear oO. 我的问题是:当我选择到标签栏控制器2时,导航栏出现oO。 I've read through the internet that I can't push a tab bar controller into a navigation stack, is that true? 我已经阅读了互联网,无法将标签栏控制器推入导航堆栈中,对吗?

So what is the solution for my UI? 那么我的UI的解决方案是什么? Since I want the user to be able to go back to that test screen, but I want to use this tab bar controller as well. 因为我希望用户能够返回到该测试屏幕,但是我也希望使用此选项卡栏控制器。

Thanks in advance! 提前致谢!

I've read through the internet that I can't push a tab bar controller into a navigation stack, is that true? 我已经阅读了互联网,无法将标签栏控制器推入导航堆栈中,对吗?

Yes, it's true. 对,是真的。

Take a look at the documentation for -[UINavigationController pushViewController:animated:] , which says this about the view controller it takes as a parameter: 看看-[UINavigationController pushViewController:animated:] 的文档 ,它说明了有关它作为参数的视图控制器的信息:

This object cannot be an instance of tab bar controller and it must not already be on the navigation stack. 该对象不能是选项卡栏控制器的实例,并且它一定不能已经在导航堆栈中。

(Emphasis added.) (已添加重点。)

So what is the solution for my UI? 那么我的UI的解决方案是什么?

Organize your application differently. 以不同的方式组织您的应用程序。 One way would be to make the tab controller your root controller and present the initial view controller modally when the app first starts. 一种方法是使选项卡控制器成为根控制器,并在应用程序首次启动时以模态显示初始视图控制器。 If the user needs to get back there, provide a button or some other means that displays the initial view controller modally again. 如果用户需要回到那里,请提供一个按钮或其他方式再次以模态方式显示初始视图控制器。 Or just make that initial screen another tab, so that the user can get back to it at any time. 或者只是将初始屏幕设为另一个选项卡,以便用户可以随时返回到它。

I'm using this to push a Tab Controller on top of a navigation controller. 我正在使用它来将选项卡控制器推到导航控制器的顶部。 Just give you Tab Controller or Navigation Controller an identifier on the attributes inspector. 只需在属性检查器上为Tab Controller或Navigation Controller提供一个标识符即可。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *tab=[storyboard  instantiateViewControllerWithIdentifier:@"tabController"];
[self.navigationController presentViewController:tab animated:YES completion:nil];

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

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