开发者

iPhone Objective-C: Disable the popping of the stack when clicking the tab with a navigation controller

Let's say开发者_JS百科 I have a Tab Bar Controller with a tab A. A has a navigation controller, which lets me push new views onto the stack. Right now, if I tap A on the Tab Bar, all of the elements in A's stack will pop.

Is there a nice way to disable this? I have a sequence of views that are displayed with the navigation controller that takes user input would not like all of that to be lost with a slip of the finger.

Thanks in advance, and please let me know if my question is unclear.


Try setting up a delegate for your UITabBarController, and implement:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

If the same view controller is being selected, return NO. Then the navigation stack should not change.

Note it will only be called for the same tab you are already on from iOS 3.0 on, but at this point I would only target iOS 3.0+.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜