mrd
mrd

Reputation: 4699

iOS: Is it possible to have a return key on number pad?

The standard keyboard in iOS does have a return key and there is a delegate method which is called when the user taps the return key.

Is it possible to have a return key on the number pad?

Upvotes: 2

Views: 2684

Answers (2)

Himanshu padia
Himanshu padia

Reputation: 7712

You can do something Like this, you can set you own toolbar position.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if( textField == yourTextField )
    {
        UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
        numberToolbar.barStyle = UIBarStyleBlackTranslucent;
        numberToolbar.items = [NSArray arrayWithObjects:
                               [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                               [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                               [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButton)],nil];
        textField.inputAccessoryView = numberToolbar;
}
}

- (void)doneButton
{
    [youtTextField resignFirstResponder];
}

Upvotes: 3

rmaddy
rmaddy

Reputation: 318774

There is no way to modify the standard number pad. The typical solution is to setup a toolbar with a button and make this view the text field's inputAccessoryView. You then call resignFirstResponder on the text field when the button is tapped.

Upvotes: 1

Related Questions