准备点击在TableView中一accessoryButton后,它会先功能,然后重定向我PrepareforSegue到accessoryButtonTappedForRowWith功能这在我的代码中创建错误。问题与Segue公司和AccessoryButtonTappedForRowWith
请看看到我的代码:
var indexPathAccessory: Int?
override func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
indexPathAccessory = indexPath.row
}
indexPathAccessory包含其中Accessorybutton被点击的行的值。 第二个功能是:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Add" {
let nc = segue.destination as! UINavigatorController
controller = nc.topViewController as! AVC
//Comment 1
controller.name = span[indexPathAccessory]
//Comment 2
controller.delegate = self
}
}
我点击accessorybutton后得到错误的原因,它是功能,然后再重定向我prepareforSegue到accessoryButtonTappedForRowWith和因值indexPathAccessory哪还没有,我得到这个错误
,才有可能第一个跳accessoryButtonTappedForRowWith得到的indexPathAccessory然后prepareForSegue价值? 如果是,问题将被解决。
我尝试添加一个测试时要返回indexPathAccessory为零。没有错误,但没有以适当的方式 应用程序运行:
我可以看到controller.name等于“测试”,但是当我在AVC视图控制器,名成为无
有没有建议吗?
我以前试过,但我没有成功,如何发送的名称和委托给下一个视图控制器! –