在警报中显示警报

时间:2017-12-10 00:40:09

标签: swift alert uialertview

我正在尝试显示一条警报,该警报会接受用户输入,然后弹出已发出的文本

@IBAction func forgotPassword(_ sender: Any) {
    //1. Create the alert controller.
    let alert = UIAlertController(title: "Email Recovery", message: "Enter your email to recover your account", preferredStyle: .alert)

    //2. Add the text field. You can configure it however you need.
    alert.addTextField { (textField) in
        textField.text = ""
    }

    // 3. Grab the value from the text field, and print it when the user clicks OK.
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak alert] (_) in
        let textField = alert?.textFields![0] // Force unwrapping because we know it exists.
        print("An email has been sent to \(String(describing: textField?.text)) for account recovery")
    }))

    // 4. Present the alert.
    self.present(alert, animated: true, completion: nil)
}

输入也可以正常输出,但它不是提供另一个警报,而是在控制台中打印我需要的内容。

我错过了什么吗?

1 个答案:

答案 0 :(得分:3)

我猜你有点误解了:" print"只是在你的控制台上打印,如果你想在触摸" ok"之后打开一个新的警报。按钮,您可能希望用以下代码完成代码:

df['A'].apply(lambda x : handler(objs.get(x)))