Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.