我的 segue 不工作
my segue is not working
我有一个按钮,如果用户点击它它必须显示另一个 vc 并且它工作正常直到我添加 UIAlertController 它从用户那里获取数据并且在用户点击完成后 alertaction 没有任何反应
这是我的代码:
@IBAction func DfsClicked(_ sender: AnyObject) {
let alertController = UIAlertController(title: "DFS?", message: "Please input DFS depth:", preferredStyle: .alert)
let confirmAction = UIAlertAction(title: "Confirm", style: .default) { (_) in
if let field = alertController.textFields?[0] {
// store your data
self.depth = Int(field.text!)!
print(self.depth)
Puzzle.AnswerNode = dfs(inputdepth: self.depth,SortedPuzzle:self.SortedPuzzle)
} else {
// user did not fill field
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }
alertController.addTextField { (textField) in
textField.placeholder = "Default is 2"
textField.keyboardType = UIKeyboardType.numberPad
}
alertController.addAction(confirmAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true)
}
使用此方法在确认操作块内执行 segue
self.performSegue(withIdentifier: <Identifier>, sender: <Any?>)
我有一个按钮,如果用户点击它它必须显示另一个 vc 并且它工作正常直到我添加 UIAlertController 它从用户那里获取数据并且在用户点击完成后 alertaction 没有任何反应 这是我的代码:
@IBAction func DfsClicked(_ sender: AnyObject) {
let alertController = UIAlertController(title: "DFS?", message: "Please input DFS depth:", preferredStyle: .alert)
let confirmAction = UIAlertAction(title: "Confirm", style: .default) { (_) in
if let field = alertController.textFields?[0] {
// store your data
self.depth = Int(field.text!)!
print(self.depth)
Puzzle.AnswerNode = dfs(inputdepth: self.depth,SortedPuzzle:self.SortedPuzzle)
} else {
// user did not fill field
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }
alertController.addTextField { (textField) in
textField.placeholder = "Default is 2"
textField.keyboardType = UIKeyboardType.numberPad
}
alertController.addAction(confirmAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true)
}
使用此方法在确认操作块内执行 segue
self.performSegue(withIdentifier: <Identifier>, sender: <Any?>)