我试图呼叫一个具有文本字段的警报控制器.但是我想立即显示数字键盘,因为用户只能输入数字. 
 
我尝试了以下,但它不工作.
我尝试了以下,但它不工作.
let alert = UIAlertController(title: "New rating",message: "Rate this!",preferredStyle: UIAlertControllerStyle.Alert)
  let cancelAction = UIAlertAction(title: "Cancel",style: .Default,handler: { (action: UIAlertAction!) in })
  let saveAction = UIAlertAction(title: "Save",handler: { (action: UIAlertAction!) in
    let textField = alert.textFields![0] as UITextField
    textField.keyboardType = UIKeyboardType.NumberPad
    self.updaterating(textField.text)
  })
  alert.addTextFieldWithConfigurationHandler { (textField: UITextField!) in }
  alert.addAction(cancelAction)
  alert.addAction(saveAction)
  self.presentViewController(alert,animated: true,completion: nil)
解决方法
 发现自己!这可能对别人有用. 
  
  
 
        alert.addTextField(configurationHandler: { textField in
    textField.keyboardType = .numberPad
})