开发者

Change ViewController for a TabBarItem

Is it possible to change/replace ViewContoller (and View) for one of the Tabs in a UITabBarController?

I would like to switch between 3 different ViewControllers in any order from开发者_JS百科 a specific Tab (that´s why NavigationController is not possible).


They are set (in mass) using setViewControllers:animated: so you could do something like this.

// Assume tabController is the tab controller 
// and newVC is the controller you want to be the new view controller at index 0
NSMutableArray *newControllers = [NSMutableArray arrayWithArray:tabController.viewControllers];
[newControllers replaceObjectAtIndex:0 withObject:newVC];
[tabController setViewControllers:newControllers animated:YES];

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜