简体   繁体   English

iPhone-如何检测切换选项卡视图和BackBarButtonItem?

[英]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.

相关问题 如何在iPhone的一个标签下显示视图和子视图? - How can I have a view and a subview under one tab on the iphone? iPhone-每次我们从一个选项卡切换到另一个选项卡时如何获取主视图(第一视图) - iPhone- How to get the main view (1st view) every time when we switching form one tab to another tab 如何在不引入View或Tab控制器的情况下将核心位置数据集成到我的空白iPhone App中? - How can I integrate core location data to my blank iPhone App without introducing View or tab controller? 如何在iPhone上检测LocallApStore工具? - How can I detect LocallApStore tool on the iPhone? iPhone,我如何向mainWindow添加一次显示一次的视图,但没有标签栏按钮? - iPhone, how can I add a first view, show once, to a mainWindow but not have a tab bar button? 如何检测[在App-Delegate中]用户将视图从标准更改为缩放到iPhone的显示设置 - How can i detect [ in App-delegate ] that user changed view from standard to zoomed in Display settings of iphone 如何禁用当前视图中显示的backBarButtonItem? - How to disable backBarButtonItem displayed in current view? iPhone:切换到另一个视图并返回相同的视图后,如何保留这些值? - iPhone: How do I retain the values after switching to another view and returning back to the same view? iPhone视图切换 - iPhone View Switching 谁能解释 backBarButtonItem Action 是如何被覆盖的? - can anyone explain how backBarButtonItem Action is overrided?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM