Raymond Led Carasco
Raymond Led Carasco

Reputation: 239

NavigationBar back button strange behavior and not working

I have encountered a strange behavior on the back button of a navigation bar. I will try my best to describe with with screenshots(through links, as I cant not upload yet)

Here is the first screen, or the parent view with the navigation bar hidden: Screen 1

Here is the code for first screen:

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.navigationBarHidden = false
    // Do any additional setup after loading the view.
}
override func viewWillAppear(animated: Bool) {
    self.navigationController?.navigationBarHidden = false
}

This is my code for pushing the view controller:

var second = self.storyboard?.instantiateViewControllerWithIdentifier("As_ThirdViewControllerID") as! As_ThirdViewController!

self.navigationController?.pushViewController(second, animated: true)

When you click the last tab bar button, it will bring you to a second screen: Screen 2

Same code as first screen, only, the navigation bar is NOT hidden

Now, in that second screen, you can see a BUTTON...when you click the button you will be brought to the third and last screen: Screen 3

Same code as first screen, only, the navigation bar is NOT hidden

THE STRANGE BEHAVIOR: When I swipe going back(third screen -> second -> parent) -- ITS WORKING.. When I press back button from the THIRD and last screen --> it looks like this: Screen 4 -- NOT WORKING, not going back to the previous screen...the word "back" suddenly goes away from the arrow

I don't have a lot of codes in my classes as of now as I am just starting and formulating the design, so I could not figure out what's wrong with my program..

Upvotes: 2

Views: 4047

Answers (2)

Raymond Led Carasco
Raymond Led Carasco

Reputation: 239

I could not edit my own post, the site says it has unformatted codes, when all I have added was a sentence below the post that had codes in it before I even edited it. I don't what happened.

But here's what I did:

It appears this is a bug in iOS, I saw a similar post and no one has solved the problem itself:

Navigation stack becomes unusable after canceling iOS 7 back swipe gesture

I just followed the suggestion and disabled the interactivePopGestureRecognizer

Upvotes: 0

Rohit Kumar
Rohit Kumar

Reputation: 887

This usually happens when you have navigationController stack and navigationBar stack mismatch.

Try adding custom button and selector then pop using

self.navigationController.popViewController(viewController);

Upvotes: 1

Related Questions