我確實有三個TextField如何關閉鍵盤?
對於名稱電話和電子郵件。
在選擇每一個文本框的鍵盤就會出現
-(void)createdTextField{
phoneField = [[UITextField alloc]initWithFrame:CGRectMake(225, 306, 90, 31)];
[phoneField setPlaceholder:REQUIRED];
[phoneField setBorderStyle:UITextBorderStyleRoundedRect];
phoneField.delegate = self;
phoneField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
phoneField.keyboardType = UIKeyboardTypeNumberPad;
[phoneField setTag:10];
[self.view addSubview:phoneField];
[self.view addSubview:phoneField];
nextPhoneField = [[UITextField alloc]initWithFrame:CGRectMake(325, 306, 142, 31)];
[nextPhoneField setBorderStyle:UITextBorderStyleRoundedRect];
nextPhoneField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
nextPhoneField.delegate = self;
nextPhoneField.keyboardType = UIKeyboardTypeNumberPad;
[nextPhoneField setTag:11];
[self.view addSubview:nextPhoneField];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(225, 265, 242, 31)];
[nameField setPlaceholder:REQUIRED];
[nameField setBorderStyle:UITextBorderStyleRoundedRect];
nameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
// [nameField setAutocorrectionType:UITextAutocorrectionTypeNo];
[nameField setTag:12];
[self.view addSubview:nameField];
eMailField = [[UITextField alloc]initWithFrame:CGRectMake(225, 347, 242, 31)];
[eMailField setPlaceholder:REQUIRED];
[eMailField setBorderStyle:UITextBorderStyleRoundedRect];
eMailField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
eMailField.keyboardType = UIKeyboardTypeEmailAddress;
[eMailField setAutocorrectionType:UITextAutocorrectionTypeNo];
[eMailField setTag:13];
[self.view addSubview:eMailField];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
@When在所有四個文本框,我需要取消鍵盤打字返回按鈕時關閉鍵盤。
它只發生在手機沒有剩餘的TextField。
[編輯UITextField時如何忽略鍵盤](http://stackoverflow.com/questions/274319/how-do-you-dismiss-the-keyboard-when-editing-a-uitextfield ) –
對於手機TextField它是解僱和下一個TextField其解僱鍵盤和其餘的東西它不解除鍵盤 – user891268