[英]How use Back Button in Navigation Item
當有一個ViewController
並插入Navigation Item
,將自動創建一個Back按鈕。 在我的tableView中,我使用didSelectRowAtIndexPath
來區分ViewS
並且此視圖使用相同的導航項,但不創建后退按鈕。
后退按鈕是在推送/搜索時自動創建的。 如果要自己創建此功能,則必須設置UINavigationItem的leftBarButtonItem
屬性,並實現一種方法來調用:
func backBTPressed() {
self.navigationController.popViewControllerAnimated(yes)
}
看到:
您還可以在方法tableView:didSelectedRowAtIndexPath中的上一個視圖控制器中進行推送:
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
var newViewController = ..
self.navigationController!.pushViewController(newViewController, animated: true)
}
完成了。 后退按鈕已經在那里。
您可以嘗試放松賽格。 檢查以下鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.