我希望我的swift應用程序在按下UITableViewRowAction「Edit」時打開一個UIViewController(稱爲「SecondViewController」)。不過,我下面的代碼並沒有做任何事情;當我按下「編輯」操作時,絕對沒有任何反應。當按下「編輯」UITableViewRowAction時,無法切換到另一個UIViewController
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]
}
這怎麼能解決?這甚至有可能嗎?如果需要更多信息,請發表評論。
我認爲導航控制器是零。請在故事板 –
Ha中添加導航控制器,這非常簡單。不知道我需要有一個uinavigationcontroller這個工作。謝謝。把它作爲答案(只是複製粘貼),以便我可以將其標記爲正確。 – Bossvanlindt
我已經回答。請檢查 –