如何在警报中设置键盘类型

时间:2018-06-29 15:04:47

标签: swift keyboard uialertcontroller

我有以下代码,该代码使用警报来收集用户的电子邮件地址。我想指定键盘类型,但还无法弄清楚如何在警报中执行此操作。有人可以帮助您显示如何设置.keyboardType = UIKeyboardType.emailAddress吗?

var userInput: String = ""
let prompt = UIAlertController.init(title: nil, message: "Enter your email address", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.default) { (action) in
    userInput = prompt.textFields![0].text
    if (userInput!.isEmpty) {
        return
    }
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in
    print(action)
}
prompt.addTextField(configurationHandler: nil)
prompt.addAction(okAction)
prompt.addAction(cancelAction)
self.view?.window?.rootViewController?.present(prompt, animated: true, completion: nil)

1 个答案:

答案 0 :(得分:2)

使用addTextfield行进行切换。基本上,这就是您所暗示的文本字段配置的地方。

>>>chunksize = size of chunk
>>> for chunk in pd.read_csv(filename, chunksize=chunksize,low_memor = False):
           process(chunk)