Reputation: 159
I am using a tableView Controller and in it I have 4 sections. 1st section contains 2 textfields, 2nd one has 4 textfields, 3rd one has 7 and so on. The problem which I am facing is that I am not able to navigate through the textfields by pressing the next and previous buttons on the keyboard. Actually I have tried a lot of open source libraries to put "Next" and "previous" button on a toolbar above the keyboard but not been able to do so. Every time the keyboard loads there is no toolbar above it.
Maybe It is due to the textfields inside the tableview cell. Can anybody suggest me the solution to do that.
Upvotes: 1
Views: 83
Reputation: 6918
Try:
UIToolbar* toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
toolbar.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *barItem = [[UIBarButtonItem alloc]initWithTitle:@"Previous" style:UIBarButtonItemStyleDone target:self action:@selector(prev)]
toolbar.items = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:self action:@selector(nextTF)],barItem,nil];
[toolbar sizeToFit];
self.yourTextField.inputAccessoryView = toolbar;
Next do:
-(void)prev
{
//previous
}
-(void)nextTF
{
//next
}
Upvotes: 1