UINavigationController popViewControllerAnimated: crash in iOS 6

The code below works fine in iOS 4 and 5, but crashes in iOS 6 with EXC_BAD_ACCESS . I would appreciate any help in resolving it. This code is called in the UITableViewController , which handles the application search logic:

 CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; transition.type = kCATransitionFade; [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self.navigationController popViewControllerAnimated:NO]; 

The way to add a tableView similar and is not called when called:

 SearchTVC *searchTable = [[SearchTVC alloc] init]; searchTable.detailViewController = self.detailViewController; CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; transition.type = kCATransitionFade; [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self.navigationController pushViewController:searchTable animated:NO]; 

What could be the problem?

* CHANGE

Interestingly, the crash does not occur if I use [self.navigationController popViewControllerAnimated:YES]; ( YES , not NO ). But of course, this defeats the goal of using custom pop animations.

+4
source share
2 answers

I know that my question was vague, but I had nothing more to do. I knew that the problem with the line [self.navigationController popViewControllerAnimated:NO]; was a problem, but I could not understand why. Then I stumbled upon this question , and the first answer suggested I make my instance variable lookup table, rather than creating a new one every time I want to present it, and that actually worked. This is a memory problem with which I cannot wrap my head.

tl; dr :

Ensure that the UIViewController that was UIViewController and UIViewController is an instance variable.

+2
source

Check if you have a string like the following in your controller code of the form:

 self.navigationController.delegate=self; 

If so, then you should install it back

 self.navigationController.delegate=nil; 

before you say

 [self.navigationController popViewControllerAnimated:YES]; 

Otherwise, popViewControllerAnimated first free the delegate, and then try to call it, which will result in a failure.

+7
source

Source: https://habr.com/ru/post/1435987/


All Articles