Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'search contents navigation controller must not change between -setActive:YES and -setActive:NO'

like image 545
Omar Freewan Avatar asked Feb 20 '23 12:02

Omar Freewan


2 Answers

[self.navigationController popViewControllerAnimated:YES];

will take you back to the previous view controller that was stacked in this navigation controller. that should do it..

like image 150
David Ben Ari Avatar answered Feb 23 '23 02:02

David Ben Ari


My Problem was the searchdisplay controller cannot setActive by the uinavigator so i solve my problem by add the following code :

[self.searchDisplayController setActive:NO];

[self.navigationController popViewControllerAnimated:YES];

the Error was :

* Assertion failure in -[UISearchDisplayController setActive:animated:], /SourceCache/UIKit_Sim/UIKit-1914.84/UISearchDisplayController.m:617 2012-05-13 19:07:44.696 MyApp[3648:11903] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'search contents navigation controller must not change between -setActive:YES and -setActive:NO'

like image 45
Omar Freewan Avatar answered Feb 23 '23 01:02

Omar Freewan