I am using this one in my application for adding UITextFields to my UITableViewCells, am now at a loss how I can let the user jump to the next item by using the next button in toolbar in keyboard,Here my code
IBOutlet UITextField *contNo,*breed,*coat,*color,*birthdate;
IBOutlet UIToolbar *toolBar;
IBOutlet UIBarButtonItem *barButton;
NSArray *fieldsArray;
fieldsArray = [[NSArray alloc] initWithObjects:birthdate,contNo, breed,homeAddress, coat,color, nil];
-(IBAction)next
{
for (int i=0; i<[fieldsArray count]; i++)
{ if ([[fieldsArray objectAtIndex:i] isEditing] && i!=[fieldsArray count]-1)
{
[[fieldsArray objectAtIndex:i+1] becomeFirstResponder];
if (i+1==[fieldsArray count]-1)
{
[barButton setTitle:@"Done"];
[barButton setStyle:UIBarButtonItemStyleDone];
}else
{
[barButton setTitle:@"Done"];
[barButton setStyle:UIBarButtonItemStyleBordered];
}
break;
}
}
}
-(IBAction) previous
{
for (int i=0; i<[fieldsArray count]; i++)
{
if ([[fieldsArray objectAtIndex:i] isEditing] && i!=0)
{
[[fieldsArray objectAtIndex:i-1] becomeFirstResponder];
[barButton setTitle:@"Done"];
[barButton setStyle:UIBarButtonItemStyleBordered];
break;
}
}
}
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField setInputAccessoryView:toolBar];
for (int i=0; i<[fieldsArray count]; i++)
{
if ([fieldsArray objectAtIndex:i]==textField)
{
if (i==[fieldsArray count]-1)
{
[barButton setStyle:UIBarButtonItemStyleDone];
}
}
}
}
When i try with the textfields outer the tabelview the next and previous working properly.The next and previous not working with the inside uitextfield inside the tabelview.Can any one pls help me to sort out