0

I do have Three TextField

For Name Phone and Email.

On selecting each textField keyboard will appears

-(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 to dismiss keyboard when typing return button in all four textField I need to dismiss the keyboard.

Its happen only for the phone no the remaining TextField.

user891268
  • 1,425
  • 5
  • 20
  • 25
  • possible duplicate of [How do you dismiss the keyboard when editing a UITextField](http://stackoverflow.com/questions/274319/how-do-you-dismiss-the-keyboard-when-editing-a-uitextfield) – Marek Sebera Sep 30 '11 at 07:41
  • For the Phone TextField it is dismiss and next TextField its dismiss the keyboard and remaining things its not dismissing the keyboard – user891268 Sep 30 '11 at 07:46

4 Answers4

1

I saw the code you paste. There is no delegate of the last two textfields. I think this is the reason.

lin zheng
  • 40
  • 3
0

Any time you want the keyboard hidden for a give field just do:

[myField resignFirstResponder];

As apparently myField is the field currently active.

Marin Todorov
  • 6,377
  • 9
  • 45
  • 73
0

How to Dismiss UITextField Keypad

[textField resignFirstResponder];

If you want to dismiss when user touch 'return' button, use this (Needed to set delegate and protocol, )

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}
ChangUZ
  • 5,380
  • 10
  • 46
  • 64
-1
after creation of urEachTextField


   urEachTextField = [[UITextField alloc] initWithFrame:CGRectMake(225, 265, 242, 31)];
    urEachTextField.delegate=self;

head file .h

    @interface urViewController : UIViewController<UITextFieldDelegate>
user891268
  • 1,425
  • 5
  • 20
  • 25