如何实现正确的uinavigationbar后退按钮功能 [英] How to implement the correct uinavigationbar back button functionality
问题描述
当我单击搜索显示控制器的取消按钮时,我想回到上一个视图控制器,我使用了代码:
I want to go back to the previous view controller when i click on the cancel button of my search display controller i used the code :
[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex:0] animated:YES];
但是它给了我以下错误:
but it gives me the following error :
* 由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'搜索内容 导航控制器不得在-setActive:YES和 -setActive:否'
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'search contents navigation controller must not change between -setActive:YES and -setActive:NO'
推荐答案
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
将带您回到该导航控制器中堆叠的上一个视图控制器.应该这样做.
will take you back to the previous view controller that was stacked in this navigation controller. that should do it..
这篇关于如何实现正确的uinavigationbar后退按钮功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!