Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Logging In and Logging Out

Roderick Kar
Roderick Kar
8,456 Points

unexpected behaviour with self.navigationItem.hidesBackButton using Swift

i am following the lesson using Swift. when the app first starts up without previously logged in, the back button doesn't appear as it's supposed to be, but the title of InboxViewController appears.

the fix appears to be calling self.navigationItem.hidesBackButton = true from InboxViewController instead of LoginViewController, like below:

class InboxViewController: UITableViewController { override func viewDidLoad() { var currentUser = PFUser.currentUser() if currentUser != nil { println("Current user: (currentUser.email)")

    } else {
        self.performSegueWithIdentifier("showLogin", sender: self)
    }
}

@IBAction func logout(sender: AnyObject) {
    PFUser.logOut()
    self.performSegueWithIdentifier("showLogin", sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showLogin"{
        println("showLogin seque called")
        let bottomBar = segue.destinationViewController as LoginViewController
        bottomBar.hidesBottomBarWhenPushed = true
        bottomBar.navigationItem.hidesBackButton = true
    }
}

}

1 Answer

Pavel Fomchenkov
Pavel Fomchenkov
20,897 Points

Can confirm. Also following this course Swift-wise.