【问题标题】:my segue is not working我的转场不工作
【发布时间】:2016-11-25 18:17:39
【问题描述】:

我有一个按钮,如果用户点击它,它必须显示另一个 vc 并且它工作正常,直到我添加 UIAlertController 它从用户那里获取数据并且在用户点击完成后警报操作没有任何反应 这是我的代码:

    @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)
}

【问题讨论】:

    标签: swift segue uialertcontroller


    【解决方案1】:

    使用此方法执行 segue,在确认操作块内

    self.performSegue(withIdentifier: <Identifier>, sender: <Any?>)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      相关资源
      最近更新 更多