Problem while multiple pop and push operation performed on UINavigationController programmatically with animation NO. ( iOS7 iPhone Only )

Source Code https://github.com/abhishek9284/NavigationBarTest

To understand problem consider following view tree.
( I use UITableViewController in my application )
Right click and select open image in new tab to see large image. enter image description here

Bug Info
Right click and select open image in new tab to see large image. enter image description here

Bug/Problem occurs while performing following navigations.

  1. Push one by one view manually and goto D view.
    (PUSH : Root > Alphabets > A > B > C > D)
  2. Pop multiple views at once programmatically using popToViewController and go back to Root view.
    (POP : Root < Alphabets < A < B < C < D)
  3. Push programmatically and goto 2 view.
    (PUSH : Root > Numbers > 1 > 2)

in above step 2 and 3 pop and push done programmatically with animation NO, which makes UINavigationBar back button and title very strange.

NOTE : Above problem occurs only in iOS 7 & work perfectly in iOS 6.

有帮助吗?

解决方案

★☆★ SOLVED ★☆★

Reason for problem

  • Doing push or pop inside -(void)viewDidAppear:(BOOL)animated method makes navigation stack unstable.

Solution

  • Create separate method for push or pop related process and call that method from another view controller (avoid push or pop inside -(void)viewDidAppear:(BOOL)animated)

  • After push operation call method [self.navigationController.view layoutSubviews]; which lays out subviews.

其他提示

For technical accuracy, one should not call layoutSubviews directly, even though it does work. Check Apple documentation for more info.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top