設置UItextField的邊框
[resultTextFieldsetBorderStyle:UITextBorderStyleRoundedRect];
彈出數字鍵盤:
將UITextField的keyboardType設置為:
UIKeyboardTypeNumberPad
就能彈出數字鍵盤
鍵盤類型
typedef enum {
UIKeyboardTypeDefault, 默認鍵盤,支持所有字符
UIKeyboardTypeASCIICapable, 支持ASCII的默認鍵盤
UIKeyboardTypeNumbersAndPunctuation, 標准電話鍵盤,支持+*#字符
UIKeyboardTypeURL, URL鍵盤,支持.com按鈕 只支持URL字符
UIKeyboardTypeNumberPad, 數字鍵盤
UIKeyboardTypePhonePad, 電話鍵盤
UIKeyboardTypeNamePhonePad, 電話鍵盤,也支持輸入人名
UIKeyboardTypeEmailAddress, 用於輸入電子 郵件地址的鍵盤
UIKeyboardTypeDecimalPad, 數字鍵盤 有數字和小數點
UIKeyboardTypeTwitter, 優化的鍵盤,方便輸入@、#字符
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
} UIKeyboardType;
隱藏鍵盤:
1、點擊空白處隱藏鍵盤
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[resultTextFieldresignFirstResponder];
[resultTextFieldresignFirstResponder];//點擊空白處也要隱藏鍵盤
}
2、點擊return按鈕鍵盤消失
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
returnYES;
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
}