[英]How use Back Button in Navigation Item
When a have an ViewController
and insert Navigation Item
create automatically a Back button. 当有一个
ViewController
并插入Navigation Item
,将自动创建一个Back按钮。 In my tableView i use an didSelectRowAtIndexPath
to case into the ViewS
and this views are using the same navigation Item, but dont create the back button. 在我的tableView中,我使用
didSelectRowAtIndexPath
来区分ViewS
并且此视图使用相同的导航项,但不创建后退按钮。
The back buttons are created automatically on a push/segue. 后退按钮是在推送/搜索时自动创建的。 If you want to create this functionality yourself you would have to set the
leftBarButtonItem
property of the UINavigationItem and implement a method to call: 如果要自己创建此功能,则必须设置UINavigationItem的
leftBarButtonItem
属性,并实现一种方法来调用:
func backBTPressed() {
self.navigationController.popViewControllerAnimated(yes)
}
See: 看到:
Add a back arrow to leftBarButtonItem? 向leftBarButtonItem添加后退箭头?
creating back arrow shaped leftBarButtonItem on UINavigationController 在UINavigationController上创建形状为leftBarButtonItem的后退箭头
You can also do a push in your previous view controller in the method tableView:didSelectedRowAtIndexPath: 您还可以在方法tableView:didSelectedRowAtIndexPath中的上一个视图控制器中进行推送:
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
var newViewController = ..
self.navigationController!.pushViewController(newViewController, animated: true)
}
And it is done. 完成了。 The back button is already there.
后退按钮已经在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.