我已經創建了UIAlertController和UITextField,而且UITextField只需要取0-100之間的整數。如何限制UIAlertController上的UITextField只接受指定範圍的數字?
我該怎麼做?
這是我的代碼
let confirm = UIAlertController(title: "I want to reserve", message: "sometext", preferredStyle: UIAlertControllerStyle.alert)
confirm.addTextField(configurationHandler: { (textField) in
textField.placeholder = "Please fill the number between 0-100"
})
confirm.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.default, handler: nil))
confirm.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.destructive, handler: { (action) in
self.isReserve = true
self.reservedIcon.alpha = 0
self.reservedTitle.alpha = 0
self.cancelReservedIcon.alpha = 1
self.cancelReservedTitle.alpha = 1
}))