简体   繁体   中英

How to manually add a Back button to my NavigationBar?

I would like to know how I can add a back button to my UINavigationBar , I know that If I embed in a Navigation Controller in my main view, that all of this would happen automatically, but that is not what I am trying to do, in fact, the back button could go to any other view I connect the segue to, doesn't even have to be the back.

The back button needs to be the system navigation "back" button, I don't want to have to set image files for my buttons.

I tried dragging in a bar button item in storyboard but nothing shows up, doesn't seem to be doing the trick. The navigation bar was dragged to the view in storyboard (not created programmatically) and it shows up just fine.

I looked at the following similarly asked questions:

-> How do i add a 'back' button to a UINavigationBar manually?

-> How to add a button to UINavigationBar?

-> How to programmatically add a UINavigationBar and a back button on it

but they all point to just embedding the view in a navigation controller, which again, is not what I am trying to do.

If someone can please help me out, provide some sample code I would greatly appreciate it.

Try drag-drop a UIButton object. I have always added manual back button (hardly took the in-built one)

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