Ich versuche, einen Alarm-Controller, der ein Textfeld hat aufrufen. Aber ich möchte sofort das Nummernblock zeigen, da der Benutzer nur Zahlen eingeben sollte. Ich habe mit dem folgenden versucht, aber es funktioniert nicht.Wie ein Nummernblock in einem Textfeld eines Alarm-Controllers [swift]
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", style: .Default, 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)
Dies sollte nun 'UIKeyboardType.numberPad' –