[英]IPhone - how can i detect switching tab view and BackBarButtonItem?
I need to detect the Navigation BackBarButton and View while switching tab on Tab based application . 我需要在基于Tab的应用程序上切换Tab时检测导航BackBarButton和View。 How can i achieve this.
我怎样才能做到这一点。 i need code sample
我需要代码示例
NavigationBar is drawn after the viewController that is pushed loads. NavigationBar在被加载的viewController之后绘制。 Also, that modalViewController's sit ontop of the topViewController in the 'stack' on the navigationController.
另外,该modalViewController位于navigationController的“堆栈”中topViewController的顶部。 and to detect a UINavigationController's back button press is by verifying that the current view controller is not present in the in the navigation controller's view controller stack.
要检测UINavigationController的后退按钮,请通过验证导航控制器的视图控制器堆栈中是否不存在当前视图控制器来按下。 It can safely check this condition in - (void)viewDidDisappear:(BOOL)animated as logically, by the time that method is called it would be extremely likely that the view controller was removed from the stack.
它可以安全地在-(void)viewDidDisappear:(BOOL)中以动画方式安全地检查此条件,在调用该方法时,很可能已将视图控制器从堆栈中删除。 Switching view or the same view can be detect by using navigationController.topViewController and backBarButtonItem is triggered by using isKindOfClass.
可以使用navigationController.topViewController来检测切换视图或同一视图,而使用isKindOfClass可以触发backBarButtonItem。 Here is the example that works for me.
这是对我有用的示例。
- (void)viewDidDisappear:(BOOL)animated{
if ([self.navigationController.topViewController isKindOfClass:[SDWebImageRootViewController class]]) {
NSLog(@"Is kind of");
//condition goes here
}
if (!self.navigationController.topViewController) {
NSLog(@"Is kind of topViewController");
//condition goes here
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.