0

i am using a uitableview with one section and five cells, and two different uitextfields on each tableCell.

my problem is: when a user tabs on first textfield on first table row, keyboard comes up, then the user taps on the second textfield. the keyboard DISMISS and SHOW.

so how can i keep the keyboard up instead of DISMISS and SHOW when the user switching focus on textfields?

thanks.

first edit: sorry for the late response on this, the code is a bit complicated to show in here. i do not resignFirstResponder/becomeFirstResponder in any of the textField delegate methods. could you please throw in any ideas on top of your head. thanks for all your help.

second edit: sorry for my bad mistake, i totally misunderstood my problem. i will relink the new post in here in a minute.

third edit: this is my new question

Community
  • 1
  • 1
triston
  • 365
  • 1
  • 8
  • 22

2 Answers2

1

This should work for you... Just a guess work from my side as you had not posted any code:

-(BOOL)textFieldShouldReturn:(UITextField *)textField 
{
    if(textField == firstTextfield)
    {
        if([[firstTextfield stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0)
        return NO;

        [firstTextfield resignFirstResponder];
        [secondTextField becomeFirstResponder];

        return YES;
     }

     else if(textField == secondTextField)
     {
         //Anything u want here
         return YES;
     }
    return NO;
 }
1

Normally the keyboard doesn't dismiss on its own when you switch fields.
If you are using a textfield delegate and are responding to "editingDidEnd" by resigningFirstResponder, then you will see that behavior.

If that is the case, after you leave the field, it is calling one of the methods and resigning the keyboard, then when you touch the other field, it is calling the firstResponder.

So, look for some code where you are setting a textfield delegate to call one of the textfield selector methods. Find the method that is being called and see if it is resigingFirstResponder.

If it is, then you may need to remove it or wrap it in some appropriate logic.

CocoaEv
  • 2,956
  • 18
  • 21