Alright - I'm implementing a UIToolbar
consisting of a Done button onto a UIKeyboardTypeDecimalPad
for a text field.
Problem is, the method that will resign the responder on the text field is not being called. I have put in NSLogs to see what is being called and what isn't, and the setup is called (i.e. UIToolbar initialization, button adding, adding the toolbar to the text field, etc.), but the method isn't ever called when the "Done" button is pressed. In fact, the button doesn't even look "clickable".
- (void) viewDidLoad
{
UIToolbar *toolbar = [[UIToolbar alloc] init];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(donePicker:)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolbar setItems:@[doneButton, spaceItem]];
self.textField.inputAccessoryView = toolbar;
}
-(void)donePicker:(id)sender
{
[self.textField resignFirstResponder];
}
I've attempted to use both [self.textField resignFirstResponder]
as well as [self.view endEditing:YES]
, both bearing no fruit here. Any ideas, folks?