0
votes

I have a profile that is embedded in a navigation controller. When I create a segue that goes to another view controller (also embedded in a navigation controller), I get the screen below. I used to seeing the back button that, in this case, would say "< Profile" but all I see is a blank nav bar with no back button, SOS!

Can anybody help me fix this issue? I can't seem to find any help!

This is the code I have written for the segue to go from the profile view controller to the followers view controller, which is the one with the blank nav bar.

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "toFollowers" {
        var profileVC: FollowersViewController = segue.destinationViewController as! FollowersViewController
        profileVC.followers = true

    }

}

enter image description here

2
Can you please post your code here?Nimit Parekh
Check if the view controller has a title. That is the text that is shown on the back button when the child view controller is visible. If that text is nil there will be no back button. Here is the same questionNazir

2 Answers

0
votes

Are you setting hidesBackButton = YES or backBarButtonItem = nil in profileVC, or does it have a different leftBarButtonItem defined?

Have you remove back via programmatically please remove those code.

EDITED

Following code returns how many controllers into UINavigationController please check it out it's greater then 0 or not.

var stack = self.navigationController!.viewControllers as Array

May this helps lot.

0
votes
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "toFollowers" {
//Try getting the navigation controller first as 
var navVc = segue.destination as UINavigationViewContrller
//than
var profileVc = navVc.viewControllers.first as! FollowersViewController
//        var profileVC: FollowersViewController = //segue.destinationViewController as! FollowersViewController
 //       profileVC.followers = true

    }

}