Swift/XCode 6.4:向导航栏中的导航控制器添加后退按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32404090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift/XCode 6.4: add back button to navigation controller in navigation bar
提问by SagittariusA
In my app I have this storyboard:
and I would like to add a back button from the second table view back to the first. So I inserted a Navigation controller in order to have a navigation bar in the second table view ad I have created a segue with its identifier from the second table view to the first. But then how can I add a back button? I have tried to drag a button from the library into the navigation controller but it won't let me do it...I had already done this but in this moment I can't remember how. Please can you help me?
我想将第二个表视图中的后退按钮添加回第一个。所以我插入了一个导航控制器,以便在第二个表视图广告中有一个导航栏,我创建了一个 segue,它的标识符从第二个表视图到第一个。但是我怎样才能添加一个后退按钮呢?我试图将一个按钮从库中拖到导航控制器中,但它不会让我这样做......我已经这样做了,但此刻我不记得是怎么做的。请问你能帮帮我吗?
采纳答案by Faisal Tanveer
In above image you shared you are making your tableview controller as root view controller.You have to kept your navigation controller on root. As you can see in attached image and you don't have to make back button manually as navigation controller has its own default back button.
在您分享的上图中,您正在将您的 tableview 控制器作为根视图控制器。您必须将导航控制器保留在根目录上。正如您在附加图像中看到的那样,您不必手动制作后退按钮,因为导航控制器有自己的默认后退按钮。
回答by Alexander Khitev
回答by NRitH
If you're using a navigation controller and its default navigation bar, you don't add an explicit back button--the navigation bar does it for you. You can add a UINavigationItem
to your view controller, on which you set a title, back button title, etc.
如果您使用导航控制器及其默认导航栏,则无需添加显式后退按钮——导航栏会为您完成。您可以将 a 添加UINavigationItem
到您的视图控制器,您可以在其上设置标题、后退按钮标题等。