Add minus button to uikeyboardtypenumpad

386 views Asked by At

I am trying to add minus button to UIKeyboardTypeNumPad using accessory view. My problem is that I want it to be over the keyboard ( on left to "0" key).

- (UIView *)inputAccessoryView {
if (!inputAccessoryView) {
        CGRect accessFrame = CGRectMake(0, 219, 106, 53);
        inputAccessoryView = [[UIView alloc] initWithFrame:accessFrame];
        inputAccessoryView.backgroundColor = [UIColor blueColor];
        UIButton *compButton = [UIButton buttonWithType:UIButtonTypeCustom];
        compButton.frame = CGRectMake(0, 219, 106, 53);
        [compButton setTitle: @"Word" forState:UIControlStateNormal];
        [compButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [compButton addTarget:self action:@selector(minusButtonTouched:)
         forControlEvents:UIControlEventTouchUpInside];
        [inputAccessoryView addSubview:compButton];
    }
return inputAccessoryView;
}

I can do it using keyboard hack, but i'm afraid apple might reject my app.

1

There are 1 answers

1
Vin On BEST ANSWER

This type of keyboard hack might get your app rejected by Apple. If you need an extra key, it's better to design the whole keyboard instead of adding a button on the system keyboard. That would be lot easier to implement an would look neat.

For example if you want the user to enter numeric values and some of the special characters like + or -, you can design a new keyboard with only numerals and these special characters.

Source: Numerous apps on appstore(including mine).