I am new to iPhone technology. I've saved a problem in a iPhone application, but when i use textfield keyboard type number pad the keyboard doesn't show a return/done button.
How can I hide the number pad keyboard after entering the number in the textfield? Do you have any solutions for that. Please provide help.
Depending on the iOS version your device is running and your keyboard settings, the position of the Return key may vary. Sometimes, you may find it as soon as you launch the keyboard, but in a vast majority of cases, you'll be able to access it from the num pad section by tapping on the “123” key.
It is replaced with the "Join" key so when you are done entering your password you hit "Join" and it starts the connection process.
To try it out, simply tap and hold the "123" button while you input numbers or punctuation marks. Once you're finished using the numeric keyboard, let go of the "123" button, and your keyboard will change back to its alphabet mode without the need of an extra tap.
You can do this in this way:
@property (nonatomic, strong) UITextField *textField;
- (void)viewDidLoad {
[super viewDidLoad];
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonDidPressed:)];
UIBarButtonItem *flexableItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[self class] toobarHeight])];
[toolbar setItems:[NSArray arrayWithObjects:flexableItem,doneItem, nil]];
self.textField.inputAccessoryView = toolbar;
}
- (void)doneButtonDidPressed:(id)sender {
[self.textField resignFirstResponder];
}
+ (CGFloat)toolbarHeight {
// This method will handle the case that the height of toolbar may change in future iOS.
return 44.f;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With