简体   繁体   English

向导航栏添加带有两个栏按钮项的后退按钮

[英]Adding back button to Navigation bar with two bar button items

My Navigation bar already has two bar button items on it but my intention is to have the two items and the back button that is generated when a segue to another view happens. 我的导航栏上已经有两个栏按钮项目,但我的意图是拥有这两个项目以及在对另一个视图进行定位时生成的后退按钮。

This is what I have now (image those two "items" are a menu button and a cart) 这就是我现在所拥有的(图像中的两个“项目”分别是菜单按钮和购物车) 在此处输入图片说明

This is what I want it to look like 这就是我想要的样子 在此处输入图片说明

Thanks! 谢谢!

Try the Code 尝试密码

override func viewDidLoad() { 
    let hamburgerButton = UIBarButtonItem( ... )
    let backButton = UIBarButtonItem(image: <#UIImage?#>, style: <#UIBarButtonItemStyle#>, target: self, action: Selector("backButtonPressed:"))
    self.navigationItem.leftBarButtonItems = [hamburgerButton, backButton]
}

func backButtonPressed(sender:AnyObject) {
    self.navigationController!.popViewController(true)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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