iOS中的navigationController中的后退按钮回调 [英] back button callback in navigationController in iOS

查看:557
本文介绍了iOS中的navigationController中的后退按钮回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将视图推送到导航控制器,当我按下返回按钮时,它会自动转到上一个视图。我想做一些事情,当按下后按钮,然后弹出视图离开堆栈。

3445994/948445> answer 用简单的技巧解决这个问题。

   - (void)viewWillDisappear:(BOOL)动画{
if([self.navigationController.viewControllers indexOfObject:self] == NSNotFound){
//回按钮被按下。我们知道这是真的,因为self在导航堆栈中不再是
//。
}
[super viewWillDisappear:animated];
}


I have pushed a view onto the navigation controller and when I press the back button it goes to the previous view automatically. I want to do a few things when back button is pressed before popping the view off the stack. Which is the back button callback function?

解决方案

William Jockusch's answer solve this problem with easy trick.

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
       // back button was pressed.  We know this is true because self is no longer
       // in the navigation stack.  
    }
    [super viewWillDisappear:animated];
}

这篇关于iOS中的navigationController中的后退按钮回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆