IPhone UINavigation Issue - nested push animation can result in corrupted navigation bar?

I had the same problem / error message as you did just now, was looking for a solution and ended up at this thread, however, for me I found that the solution is actually having only one animated:YES when doing a nested push (I put animated:YES only for the final push), hope this helps.

I had the same problem / error message as you did just now, was looking for a solution and ended up at this thread, however, for me I found that the solution is actually having only one animated:YES when doing a nested push (I put animated:YES only for the final push), hope this helps cheers.

Your comment allowed me to solve the puzzle -- see my comment to the accepted answer below, it may help you in the future as well. – Charles Randall May 30 '11 at 2:59 I wasn't getting an error, but my first view's navigation bar was showing the middle view's navigation bar after popping from the third view. Not animating the pop from the top solved the problem.

– Bill Sep 5 '11 at 22:14.

If you're pushing a new view controller before the old push has bad a chance to be actioned, you will get this sort of error. So putting certain code into init and doing things prematurely could certainly get you the error being reported.At the point where init is being run on a view controller, the view hasn't been loaded yet!

My only reason for saying I use init over viewDidLoad or loadView is because Apple's example app doesn't use the init methods to set up the views so I thought perhaps that could be part of it. Also, even after I commented out all the code in the init method, I still get this issue. Why wouldn't it be happening for SingleEventViewController as well, though, if that was the case?

– joshholat Apr 3 '11 at 3:48 You don't use init to set up your UI/view items -- it's not the usual place. Have a close look at UIViewController documentation. A view can be loaded from a nib.

Or you can do it programmatically in loadView. Or you can have a basic view set up via a nib, and then add more items programmatically in viewDidLoad. But you shouldn't be doing that sort of stuff in init.

– occulus Apr 3 '11 at 19:54 I do it programmatically. So should I be allocing the memory and setting all of the properties in loadView and then actually adding that stuff to the view in the init? Because if I try to to do like self.

View addSubview:myTableView; in the loadView method, it crashes. – joshholat Apr 7 '11 at 15:36.

I've figured it out. Apparently if you call -pushViewController from outside of the -didSelectRowAtIndexPath method of a UITableViewDelegate, it doesn't work. Moving the call into that function worked.Weird.

4 This solves the issue because didSelectRowAtIndexPath cannot be called until after the view has finished animating. If you simply make sure to call your pushViewController in viewDidAppear: or later, iOS will not complain about nested pushViewController calls. – Charles Randall May 30 '11 at 2:58.

Calling pushViewController before viewDidAppear is unsafe.

1) Perhaps you could try passing the necessary variables as properties before pushing the UIViewController rather than using the init methods with parameters. Most likely you will need these parameters beyond your init method anyway. Also, in your initWithCoordinates: method you are missing the parameters.

Possibly your custom init methods are a part of the problem. 2) Just because you mentioned viewDidLoad -- this method is for initialization after a view has loaded . If you create the UIViewController in code, as it seems you do, you should use loadView to set up your subviews.

The initWithCoordinates method doesn't take parameters yet. I planned on adding them but then ran into this issue first and got caught trying to debug it before moving on. However, why is that not the case with SingleEventViewController, then, too?

It takes parameters at the init that it has to set up. And thanks, I'll try with loadView. – joshholat Apr 3 '11 at 3:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions