【发布时间】:2016-08-23 17:55:58
【问题描述】:
我希望我的 swift 应用程序在按下 UITableViewRowAction“编辑”时打开一个 UIViewController(称为“SecondViewController”)。但是,我下面的代码什么也没做;当我按下“编辑”操作时,绝对没有任何反应。
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
//Edit action
let editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Edit") { (editAction, indexPath) -> Void in
let secondViewController = self.storyboard?.instantiateViewControllerWithIdentifier("secondViewController") as! SecondViewController
self.navigationController?.pushViewController(secondViewController, animated: true)
}
return [editAction]
}
如何解决?这甚至可能吗?如果需要更多信息,请发表评论。
【问题讨论】:
-
我认为导航控制器是零。请在情节提要中添加导航控制器
-
哈,这很简单。不知道我需要有一个 uinavigationcontroller 才能工作。谢谢。将其作为答案(只需复制粘贴),以便我将其标记为正确。
-
我已经回答了。请检查
标签: ios uiviewcontroller swift2 uitableviewrowaction