I have a dynamic number of UITextFields
which all have an inputAccessoryView
. This is composed of a UIToolbar
which has a button on it. When this button is pressed it calls a method, however, within this method I somehow need the ability to access the underlying UITextField
.
Please could someone advise how this is possible?
// Create the toolbar controls
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(navigationBarDoneButtonPressed:)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
// Setup the toolbar
navigationToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(10.0, 0.0, 310.0, 40.0)];
[navigationToolbar setItems:@[flexibleSpace, doneButton]];
// In a UITableView I create a number of cells which contain UITextFields....
// This is the method that gets called when a user presses the done button
- (void)navigationBarDoneButtonPressed:(id)sender
{
NSLog(@"Based on sender I need to access the underlying UITextField.");
}