将键盘类型设置为数字键盘
加上这个
func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) -> Bool { if let text = textField.text { let newStr = (text as NSString) .stringByReplacingCharactersInRange(range, withString: string) if newStr.isEmpty { return true } let intvalue = Int(newStr) return (intvalue >= 0 && intvalue <= 12) } return true}


