UITabBarController可以通过代码选择选项卡吗? [英] UITabBarController is possible to select the tab via code?

查看:129
本文介绍了UITabBarController可以通过代码选择选项卡吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UITabBarController是否可以在代码中选择选项卡?比如UINavigationController
我们可以使用popViewController弹出回rootViewController而不是按下后退按钮,那么如何在tabbarcontroller中实现呢?

is it UITabBarController possible to select the tab in code?like UINavigationController we can use popViewController pop back to rootViewController instead of press the back button, so how can this implement in tabbarcontroller?

推荐答案

在UITabBarController上使用selectedIndex属性。更多信息可以在 UITabBarController类参考

Use the selectedIndex property on the UITabBarController. More information can be found in the UITabBarController Class Reference.

controller.selectedIndex = 4;

或使用

[controller setSelectedIndex:4];

这篇关于UITabBarController可以通过代码选择选项卡吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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