UINavigationItem out of sync when using popToRootV

2019-09-01 06:05发布

问题:

I tap a tab bar item, which triggers poptoRootViewControllerAnimated. Most of the time it works as expected, but in some cases it pops to the correct view, but the navigation item is out of sync, "stuck" from the view i previously was at.

I've read about people having this problem with iPad's, when in landscape mode, but the solutions I've found don't work in this case. This is an iPhone app in portrait mode.

Happens with the simulator as well as on an actual iPhone. If someone has a suggestion or solution i'll be a very happy man!

回答1:

Turns out that the different iOS versions handle this differently. This only occured on the older versions, so we had to rebuild the stack manually there.



回答2:

do you get any message in the console like

nested push animation can result in corrupted navigation bar

and

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

if yes take a look at these few answers... but what they all basically mean is you are trying to pop from the navigation controller too early, probably before it is properly loaded...