TPKeyboardAvoiding icon indicating copy to clipboard operation
TPKeyboardAvoiding copied to clipboard

UITableView Next responder not working

Open dErangaPrasad opened this issue 10 years ago • 7 comments

I have custom cell with UITextField. but the problem is keyboard next button does not appear. It displayed as return, once I click on return nothing happen.

dErangaPrasad avatar Sep 17 '15 05:09 dErangaPrasad

just noticed. Issue occurred when you set the text field delegate. any solution for this ?

dErangaPrasad avatar Sep 17 '15 05:09 dErangaPrasad

yeah i also have the same issue it's addresed in this method

  • (void)TPKeyboardAvoiding_initializeView:(UIView_)view { if ( [view isKindOfClass:[UITextField class]] && ((UITextField_)view).returnKeyType == UIReturnKeyDefault && (![(UITextField_)view delegate] || [(UITextField_)view delegate] == (id<UITextFieldDelegate>)self) ) { [(UITextField*)view setDelegate:(id<UITextFieldDelegate>)self]; UIView *otherView = [self TPKeyboardAvoiding_findNextInputViewAfterView:view beneathView:self];

    if ( otherView ) {
        ((UITextField*)view).returnKeyType = UIReturnKeyNext;
    } else {
        ((UITextField*)view).returnKeyType = UIReturnKeyDone;
    }
    

    } }

if we set the delegate for textfield in our view controller the if condition fails. i.e. (![(UITextField_)view delegate] || [(UITextField_)view delegate] == (id<UITextFieldDelegate>)self) )

this code execute only if our textfield delegate is nil.

sulabhsuyati avatar Sep 17 '15 13:09 sulabhsuyati

@sulabhsuyati Yeah that's true. did you find any solution for that ?

dErangaPrasad avatar Sep 18 '15 02:09 dErangaPrasad

@dErangaPrasad Not yet.

sulabhsuyati avatar Sep 18 '15 05:09 sulabhsuyati

any solution? I found my solution, this is little hard work with UITableView

karthisiva avatar Jan 22 '16 09:01 karthisiva

@karthisiva It would have been nice yo share the solution.

Bashta avatar Mar 22 '16 14:03 Bashta

@Bashta This is my solution based on my condition, My suggestion, there is an another library with out any code https://github.com/hackiftekhar/IQKeyboardManager

#pragma mark UITextField Delegates -(BOOL)textFieldShouldReturn:(UITextField *)textField { NSIndexPath *indexPath; if([textField.superview.superview isKindOfClass:[RegisterCell class]]) { UITableViewCell cell = (UITableViewCell )textField.superview.superview; indexPath = [tableView indexPathForCell:cell]; } NSIndexPath *indexPathNextRow = [NSIndexPath indexPathForRow:(indexPath.row+1) inSection:indexPath.section]; RegisterCell cellNextRow = (RegisterCell )[tableView cellForRowAtIndexPath:indexPathNextRow]; int tag=(int)indexPathNextRow.row; UITextField textFieldNextRow = (UITextField )[cellNextRow.contentView viewWithTag:tag]; [textFieldNextRow becomeFirstResponder]; NSLog(@"last text field---------->%ld",(long)textField.tag); } return YES; }

  • (void)textFieldDidEndEditing:(UITextField *)textField{

    [textValues replaceObjectAtIndex:textField.tag withObject: textField.text]; }

karthisiva avatar Mar 23 '16 10:03 karthisiva