简体   繁体   English

搜索到标签栏和导航栏中的视图控制器

[英]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.

相关问题 Segue到TabBar控制器 - Segue to TabBar Controller 标签栏内的导航栏内的iPhone推送视图控制器 - iphone push view controller inside navbar inside tabbar IphoneX View隐藏在Tabbar控制器的Tabbar旁边 - IphoneX View hidden beside the Tabbar controller's tabbar 确定何时离开视图控制器不是安全的 - Determine when leaving a view controller that it's not a segue Segue无法从标签栏控制器中的ViewController运行 - Segue not working from the viewcontroller inside tabbar controller UITabBarController的tabBar显示的速度比控制器的视图慢 - UITabBarController's tabBar showed slower than controller's view 如何从该视图或目标视图控制器中访问执行视图的源视图? - How to access source view that perform segue from within that segue or destination view controller? 从tableView委托类中调用视图控制器segue - call view controller segue from within tableView delegate class 在导航栏中转到新视图 controller,memory 不断上升 - Segue to new view controller within a nav bar, the memory keeps rising 从嵌入在 UINavigationController 中的一个视图控制器转移到另一个 UINavigationController - Segue from one view controller embedded within UINavigationController to another UINavigationController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM