我正在使用以下代码:
<<< ButtonRow("MyCell") { $0.title = $0.tag $0.presentationMode = .segueName(segueName: "ShowMyScreen", onDismiss: nil) }
现在,我需要在点击时执行一个条件,只有在它是真的时才移动,如果它是假的则显示警告。如果用户点击警报中的确定,则移动。 我该怎么做?
答案 0 :(得分:1)
使用.onCellSelection
关闭
您的要求的示例代码
<<< ButtonRow("MyCell") { $0.title = $0.tag
}.onCellSelection({ (cell, row) in
if(yourCondition)
{
self.performSegue(withIdentifier: "ShowMyScreen", sender: nil)
}else{
let alert = UIAlertController(title: "test", message: "test", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: { (action) in
self.performSegue(withIdentifier: "ShowMyScreen", sender: nil)
})
let action2 = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alert.addAction(action)
alert.addAction(action2)
self.present(alert, animated: true, completion: nil)
}
})