How to manually add a Back button to my NavigationBar?

混江龙づ霸主 提交于 2019-12-23 15:10:29

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/17749838/how-to-manually-add-a-back-button-to-my-navigationbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!