开发者

TabBar Stop The Popping

If have a Navigation Bar and a Tab Bar in one of my views. This is all working fine. One of the Tab Bar items requires pushing several other view controllers on the navigation stack before I get the where I need to be. This is also working. When I click on the tab bar item, it marches right back up the stack. How ca开发者_运维技巧n I make the desired controller stick in the tab bar item?


This is a standard behaviour of the Tab Bar, if you set it up with each tab pointing to a different view controller in the main nib file. It is in fact quite useful, allowing the user to navigate deeply within a particular stack, and then press the tab button that's already selected to return to the home/top level.

Note that this behaviour only happens when you click on a tab that you already have selected. You could implement a line in the tab bar delegate that intercepts the click on a tab and disregards it if that tab is already selected.

To do this you'll need to handle the display of different view controllers manually. You want to implement this method:

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

and then push different views onto the navigation stacks yourself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜