Pergunta

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
Foi útil?

Solução

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.

Outras dicas

It is worth remembering that when viewcontroller is pushed away in navigation stack (new view controler is push in), even if it is not being released itself (retained it the navigation controller stack), its maim view is being released (with all of it's subviews of course) thou.

So this type of crash will mostly point to UI part of memory management (most problably double release of autoreleased UIImages which was my case;-).

Hope it helps someone to understand how UINavigationController manages memory.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top