UITextField get focus and then lose focus immediately due to return YES in textFieldShouldReturn

泪湿孤枕 提交于 2019-12-06 15:43:53

Just set tag your textfield and put this code

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSInteger nextTag = textField.tag + 1;
    // Try to find next responder
    UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
    if (textField.tag == 0) {
        // Found next responder, so set it.
        [nextResponder becomeFirstResponder];
    } else {
        // Not found, so remove keyboard.
        [textField resignFirstResponder];
    }
    return NO;
}

I hope this will help you great.

If you like my Answer so accept and upvote my answer

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
   NSUInteger index = textField.tag;
   if (index == 1 || textField == self.passwordTextField) 
   { 
      [textField resignFirstResponder];
   }
   else
   {
      [textField becomeFirstResponder];
   }
   return NO;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!