[英]Segue to a view controller that's within a tabbar and navbar
1 tabbarcontroller connected to 3 navigation controllers. 1个tabbarcontroller连接到3个导航控制器。 each navigation controller is connected to a view controller.
每个导航控制器都连接到一个视图控制器。 in #3 a button segues modally to a view controller.
在#3中,按钮以模态方式选择连接到视图控制器。 i dont want the segue to be "push".
我不希望segue被“推”。 is there anyway i can create a button in that view controller that segues back to #3?
无论如何,我可以在该视图控制器中创建一个按钮,将其切换回#3吗?
I want a button in "randomviewcontroller" to perform a segue to "viewcontroller3" that is within a navigation controller and tabbarcontroller. 我希望“ randomviewcontroller”中的按钮对导航控制器和tabbarcontroller中的“ viewcontroller3”执行搜索。 "viewcontroller3" is the third tabbarbutton view.
“ viewcontroller3”是第三个标签栏按钮视图。
so: 所以:
randomviewcontroller to perform segue to randomviewcontroller执行segue
TabBarController -(relationshipsegue)-> NavigationController -(rootview controllersegue)-> viewcontroller3 TabBarController-(relationshipsegue)-> NavigationController-(rootview controllersegue)-> viewcontroller3
Example: a login view controller. 示例:登录视图控制器。 you press login button, and it segues to the third tabbar button view (view that you see if you tap third icon on tabbar).
按下登录按钮,它将切换到第三个标签栏按钮视图(如果您点击了标签栏上的第三个图标,则会看到该视图)。 third tabbar button is connected to a navigation controller that is rootview of a view controller.
第三个标签栏按钮连接到导航控制器,该导航控制器是视图控制器的rootview。
如果tabbarviewcontrollers.viewcontrollers
数组中的视图控制器都是导航控制器,而您只想以编程方式切换选项卡并显示该导航控制器的根视图控制器,那么您所需要做的就是切换到要选择的选项卡的索引选择:
tabBarController?.selectedIndex = 2 //or whatever index you want
I'm not sure I quite understand your question (and I don't see why you would have a login view controller in one of your tabs, most likely it would be in a view controller of its own). 我不确定我是否完全理解您的问题(而且我不明白为什么您会在其中一个选项卡中使用登录视图控制器,很可能是在其自己的视图控制器中)。
Try connecting the button to the following code (assuming that the button is in the login tab) 尝试将按钮连接到以下代码(假设该按钮位于登录选项卡中)
-(IBAction) login:(id)sender {
[self.tabBar setSelectedItem:[self.tabBar.items objectAtIndex:2]];
}
Let me know if this works. 让我知道这个是否奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.