Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange behavior of NavigationBar after multiple push and pop with animation NO. iOS7

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.

like image 202
Abhishek Panchal Avatar asked Oct 03 '22 09:10

Abhishek Panchal


1 Answers

★☆★ 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.

like image 122
Abhishek Panchal Avatar answered Oct 13 '22 10:10

Abhishek Panchal