UITabBarController 的默认行为是当第二次点击特定选项卡时将包含的 UINavigationController 弹出到根视图控制器。我有一个特定的用例,我希望它不会自动工作,并且我很难弄清楚如何防止这种情况。
有人遇到过这种情况吗?如果有,你做了什么?我是否需要子类化 UINavigationController 并覆盖 popToRootViewController 还是有更简单的方法?
Use the tabBarController:shouldSelectViewController: http://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITabBarControllerDelegate/tabBarController:shouldSelectViewController:的方法UITabBarControllerDelegate 协议 http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITabBarControllerDelegate/.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return viewController != tabBarController.selectedViewController;
}
不要忘记将选项卡栏控制器的委托设置为实际实现此委托方法的对象。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)