I have a UITextField
which is Number Pad
and its properties look like
But when I run my application, I do not see Done
on my screen
What is the issue? How can I get Done
on Decimal Pad
?
I have a UITextField
which is Number Pad
and its properties look like
But when I run my application, I do not see Done
on my screen
What is the issue? How can I get Done
on Decimal Pad
?
The best way I've found when doing something like this is to append an inputAccessoryView
to the UITextField
. That input accessory view can have a "Done" button on it that dismisses the keyboard for you. I don't think you should put a "Done" button on the key pad itself, because where would it go?
Here's how I've done it before:
- (void)setupKeyboardAccessory {
UIToolbar *keyboardToolbar = [[UIToolbar alloc] init];
[keyboardToolbar sizeToFit];
keyboardToolbar.backgroundColor = [UIColor whiteColor];
UIBarButtonItem *flexBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *doneBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self.patientAgeTextField action:@selector(resignFirstResponder)];
keyboardToolbar.items = @[flexBarButton, doneBarButton];
self.textField.inputAccessoryView = keyboardToolbar;
}