1

当用户使用 Tabbar 打开视图控制器时,如何以编程方式“选择”设置 Tabbar 项(带有标记 0、1、2 或 3)?

[tabBar setSelectedItem:[tabBar.items objectAtIndex:2]];我在 viewdidload 中尝试过 -

(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {

但它没有用,有谁知道我如何设置选中的项目?

4

1 回答 1

0

I assume that tabBar is an outlet to a tab bar -- if that's the case, I think you need to use self.tabBar to have the change be propagated through to the UI (makes the change KVO compliant).

于 2012-05-13T23:18:58.383 回答