You can track the current focus of a UITextField in a variable and use this variable in the inputAccesoryView method:
in your .h file: make sure you comply with the UITextFieldDelegate protocol:
@interface MyViewController : UIViewController <UITextFieldDelegate>
and add this property:
@property (assign, nonatomic) UITextField *activeTextField;
In your .m file: when creating dynamic text fields:
... theTextField.delegate=self; ...
And add these implementations of the UITextFieldDelegate protocol:
- (void)textFieldDidBeginEditing:(UITextField *)textField { self.activeTextField = textField; } - (void)textFieldDidEndEditing:(UITextField *)textField { self.activeTextField = nil; }
And now, in the method called by your inputAccesoryView :
- (void)navigationBarDoneButtonPressed:(id)sender{
source share