UINavigationController拦截– popViewControllerAnimated: [英] UINavigationController intercepting – popViewControllerAnimated:

查看:198
本文介绍了UINavigationController拦截– popViewControllerAnimated:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以问题在于,当有人触摸UINavigationControler上的后退按钮时,我想运行一些代码来更新数据源.

So the the problem is that when someone touches the back button on the UINavigationControler, I would like to run some code to update the datasource.

问题是我似乎找不到合适的代表去做.导航控制器委托中只有这些功能可用,我想要'didfinishshowing'类型的方法.

The problem is that i cant seem to find the right delegate to do it. only these are available on the nav controller delegate, and i want the 'didfinishshowing' type method.

– navigationController:willShowViewController:animated:  optional method  
– navigationController:didShowViewController:animated:  optional method  

我认为第二个最好的地方是导航栏,但是当我尝试使用它时.

The next best place i thought was the nav bar but when i try that.

由于未捕获而终止应用程序 例外 'NSInternalInconsistencyException', 原因:无法手动设置 委托的UINavigationBar上的委托 由控制器

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot manually set the delegate on a UINavigationBar managed by a controller

这具有追溯意义,因为您不希望某些黑客弄乱nav控制器的内部并使它停止工作.

This makes sense retrospectively, as you don't want some hacker messing around with the internals of the nav controller and stopping it from working.

这肯定是一个常见问题,我错过了一些简单的事情.

This must is a common problem, and i have missed something simple.

推荐答案

将刷新代码添加到将要显示的视图控制器上的viewWillAppear:(BOOL)动画方法中.在您的情况下,这就是导航堆栈中已经存在的视图控制器.

Add your refresh code to the viewWillAppear:(BOOL)animated method on the view controller that is about to be displayed. In your case, that is the view controller that's already on the navigation stack.

这篇关于UINavigationController拦截– popViewControllerAnimated:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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