简体   繁体   中英

backBarButtonItem does not appear swift

I know someone did the same question, but there's no answer there.

It is supposed that when you use a NavigationBar the back button comes with it, however every time I call a segue, I don't see it in the navigation bar. Maybe is the way I'm linking the second view controller (modal) I don't know. But it seems to be a so simple thing that I haven't been able to find an example showing how to make it appear. I have no code in the details view controller to initialize the backBarButtonItem, since that's precisely what I don't know how to do.

@IBAction func onMovieTap(sender: AnyObject) {
    performSegueWithIdentifier("loadDetails", sender: self)
}

Here is the image of the segue config. https://www.dropbox.com/s/j6njfxmg07q1o4g/Captura%20de%20pantalla%202014-09-27%2000.43.15.png?dl=0

Thanks,

When you use Modal as the segue type you do not get the automatic back button.

You can either change the segue to something like: Show (eg Push) or drag a bar button item into the Navigation Bar and create an Outlet for it, something like this:

@IBAction func cancelButton(sender: UIBarButtonItem) {
    // Close your view controller, etc.
}

You would need to connect your button to this outlet by, say, CNTRL dragging from the button to the code or CNTRL dragging into your code and completing the small pop-up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM