目标C:如何通过程序从一个标签栏切换到另一个标签栏 [英] Objective C: How to switch from one Tab bar to another via program

查看:97
本文介绍了目标C:如何通过程序从一个标签栏切换到另一个标签栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标签栏控制器中有5个不同的标签。

I have 5 different tabs in my tabbar controller.

我的目的是能够通过代码从一个标签栏切换。例如,我目前在应用程序的第5个选项卡中,当我点击完成按钮时,应用程序应该将我的视图切换到属于第一个选项卡的rootview控制器。

My intention is to be able to switch from one tab bar via code. For example I am currently in the 5th tab of the app and when I click on the 'done' button, the app should switch my view to the rootview controller belonging to the 1st tab.

关于如何做到这一点的任何建议?

Any advise on how I can do this?

推荐答案

设置 selectedViewController 属性 UITabBarController

self.myTabBarController.selectedViewController = myViewController;

使用如下

self.myTabBarController.selectedViewController 
    = [self.myTabBarController.viewControllers objectAtIndex:0];

这篇关于目标C:如何通过程序从一个标签栏切换到另一个标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆