如何手动向导航栏添加后退按钮? [英] How to manually add a Back button to my NavigationBar?

查看:40
本文介绍了如何手动向导航栏添加后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何向 UINavigationBar 添加后退按钮,我知道如果我在主视图中嵌入导航控制器,所有这些都会自动发生,但是这不是我想要做的,事实上,后退按钮可以转到我将 segue 连接到的任何其他视图,甚至不必是后退按钮.

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:

->如何添加后退"按钮到手动创建 UINavigationBar?

->如何向 UINavigationBar 添加按钮?

->如何以编程方式添加 UINavigationBar 和返回按钮

但他们都指出只是将视图嵌入到导航控制器中,这又不是我想要做的.

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.

推荐答案

尝试拖放 UIButton 对象.我一直添加手动后退按钮(几乎没有使用内置按钮)

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

这篇关于如何手动向导航栏添加后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆