我想为textfield做自动填充,例如电子邮件。
我在互联网上搜索过,我没有找到swift版本,很多演示使用tableview
来显示结果。
我的问题是:
1:我不想用tableview
来显示结果,我想像safari那样做,当你写一些东西时,结果是灰色的并完成句子。
2:我想为UIAlertController
的文本字段执行自动填充功能。我UIAlertController
文本字段的代码是
let ac = UIAlertController(title: "Enter e-mail", message: nil, preferredStyle: .Alert)
ac.addTextFieldWithConfigurationHandler(nil)
let submitAction = UIAlertAction(title: "Send", style: .Default) { [unowned self, ac] (action: UIAlertAction!) in
self.dismissKeyboard()
}
答案 0 :(得分:0)
如果文本框是通过storyboard添加的,则单击然后单击文本框
然后选择AtrributeInspector - >改变校正 - >是
这将用于处理自动更正
谢谢,
答案 1 :(得分:0)
我使用Swift 5解决了这个问题:
let alert = UIAlertController(title: "Alert Title", message: "...", preferredStyle: .alert)
alert.addTextField { (textfield) in
textfield.text = "default value"
textfield.autocorrectionType = .yes
}