<分区>
我知道要使用这段代码以编程方式设置常规文本字段的高度
textField.frame.size.height = 60
但是如果我在 UIAlertController
中将此代码实现到文本字段,它就不起作用。我还尝试将键盘更改为支持 ASCII,但在我运行该应用程序后它并没有更改键盘。看来我错过了什么
这是我的警报 Controller 的代码
let alertController = UIAlertController(title: "Write Comment", message: "Tell us why you are not satisfied", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Send", style: .default, handler: { alert -> Void in
let textField = alertController.textFields![0] as UITextField
textField.frame.size.height = 60
textField.keyboardType = .asciiCapable
let commentDefect = textField.text ?? ""
self.sendComment(defectID: defectID, comment: commentDefect)
}))
alertController.view.tintColor = UIColor(red: 0/255, green: 129/255, blue: 58/255, alpha: 1)
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alertController.addTextField(configurationHandler: {(textField : UITextField!) -> Void in
textField.placeholder = ""
})
self.present(alertController, animated: true, completion: nil)
高度好像还在17左右,这是哪里出了问题?