EXC_BAD_ACCESS when popViewControllerAnimated in navigation based application

crash, iphone, navigation, popviewcontroller, uinavigationcontroller

Solution

I had faced the same problem that could be because your last view is no longer retained.The best way could be try to retain your previous view by making the property and synthesizing it.

Then try to use

[self.navigationConroller popViewControllerAnimated:YES];

or to pop to desired view

[self.navigationController popToViewController:myview animated:YES];

or to pop to rootview

[self.navigationController popToRootViewControllerAnimated:YES];

Let me know if it helps you.Because this error comes when you are attempting to go to a view which has been already released.

Problem

I can't figure out why I get crash when poping back to previous view contoller in navigation stack. The thing is I am using custom navigation bar (original is hidded and my custom buttons fires navigation - push and pop - instead). Trace I get: ``` Program received signal: “EXC_BAD_ACCESS”. #0 0x011a4a60 in objc_msgSend #1 0x0044e37c in -[UIImageView(UIImageViewInternal) _canDrawContent] #2 0x003bf3df in -[UIView(Internal) _didMoveFromWindow:toWindow:] #3 0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:] #4 0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:] #5 0x003bdfc4 in -[UIView(Hierarchy) _postMovedFromSuperview:] #6 0x003b6dfc in -[UIView(Internal) _addSubview:positioned:relativeTo:] #7 0x003b514f in -[UIView(Hierarchy) addSubview:] #8 0x005ca471 in -[UINavigationTransitionView transition:fromView:toView:] #9 0x005c9ed5 in -[UINavigationTransitionView transition:toView:] #10 0x0043c606 in -[UINavigationController _startDeferredTransitionIfNeeded] #11 0x0043c292 in -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] #12 0x0043bfa9 in -[UINavigationController popViewControllerWithTransition:] #13 0x0043f62b in -[UINavigationController popToViewController:transition:] #14 0x000124fa in -[BaseViewController bottomNavigationFiredController:] at BaseViewController.m:187 ```

Original source