Iphone 如何更改TabBarController索引和调用方法
我在选项卡栏视图的一个控制器中有一个UIButton,我希望该按钮可以更改选项卡栏selectedIndex并调用selectedIndex的控制器方法 例如: 我的按钮在索引3中选择。当用户单击按钮时,我想将selectedIndex更改为0,并在selectedIndex的控制器中调用一个方法 这可能吗?如果是,怎么做Iphone 如何更改TabBarController索引和调用方法,iphone,ios4,uitabbarcontroller,Iphone,Ios4,Uitabbarcontroller,我在选项卡栏视图的一个控制器中有一个UIButton,我希望该按钮可以更改选项卡栏selectedIndex并调用selectedIndex的控制器方法 例如: 我的按钮在索引3中选择。当用户单击按钮时,我想将selectedIndex更改为0,并在selectedIndex的控制器中调用一个方法 这可能吗?如果是,怎么做 提前谢谢 这是切换到其他选项卡的方式: - (IBAction)buttonPressed:(id)sender { self.tabBarController.s
提前谢谢 这是切换到其他选项卡的方式:
- (IBAction)buttonPressed:(id)sender
{
self.tabBarController.selectedIndex = 0;
/* Running method declared in FirstViewController */
FirstViewController *firstView = [[FirstViewController alloc] init];
// call methods here
[firstView methodName];
[firstView release];
}
是的,你可以很容易地做到……只需在你的按钮事件方法中使用这个
[self.tabBarController setSelectedIndex:3];
您的意思是在其中一个视图中有一个
ui按钮
,点击该按钮时会选择一个不同的uitabaritem
(从而改变视图,就像用户点击选项卡栏项目本身一样)?