4
- (IBAction)textFieldDoneEditing:(id)sender {
  [sender resignFirstResponder];
  [sender becomeFirstResponder];
}

I have a UItextField object, and link the "Did End On Exit" to the "textFieldDoneEditing" action. After I press the Done button on the keyboard, why is it dismissed?

tipycalFlow
  • 7,594
  • 4
  • 34
  • 45
lu yuan
  • 7,207
  • 9
  • 44
  • 78
  • 1
    What is the purpose of resining keyboard and opening in the next line – EXC_BAD_ACCESS Apr 23 '12 at 09:08
  • [sender resignFirstResponder]; will resign the textfield. I wont undrstand why u calling both [sender resignFirstResponder]; [sender becomeFirstResponder]; what exactly do u wanna do inside this function? – mChopsey Apr 23 '12 at 09:08
  • Actually i find that the keyboard is not always come up when the textfield become first responder. When the textfield is first responder and the keyboard is dismissed, how could i get the keyboard on the screen again? – lu yuan Apr 23 '12 at 09:15

2 Answers2

3

In your method call another method like bellow code

in yourViewController.h file just define bellow method

-(void)MykeyBoardUp;

and in .m file

-(void)MykeyBoardUp{
      [yourtextFieldobject becomeFirstResponder];
}

after then in your .m file in bellow method just call this method like this

- (IBAction)textFieldDoneEditing:(id)sender {
  [sender resignFirstResponder];
  [self performSelector:@selector(MykeyBoardUp) withObject:nil afterDelay:0.2];
}

May this help you......

Rashad
  • 11,057
  • 4
  • 45
  • 73
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
1

in the above code, when you run [sender resignFirstResponder] keypad will hide so calling next method is of no use

but if you still want to get keypad again, call it using UITextField object i.e.

if in .h

IBOulet UITextField *txt;

then call [txt becomeFirstResponder]

but still i don't understand, what is your purpose.

Rashad
  • 11,057
  • 4
  • 45
  • 73
cnu
  • 815
  • 10
  • 22