UITableView Next responder not working
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.
just noticed. Issue occurred when you set the text field delegate. any solution for this ?
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 Yeah that's true. did you find any solution for that ?
@dErangaPrasad Not yet.
any solution? I found my solution, this is little hard work with UITableView
@karthisiva It would have been nice yo share the solution.
@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]; }