tony.tc.leung
tony.tc.leung

Reputation: 2990

UITextField - how do i use a custom keyboard and disable the default keypad

I am using a UITextField to get input for a price field. Since it is for price, I wanted to make a custom keyboard for just a numpad and a decimal button. I have the keypad view setup, however, I dont' know how to disable the default iphone keyboard completely. Any ideas?

Upvotes: 1

Views: 4685

Answers (3)

Luda
Luda

Reputation: 7068

This could be done in the Interface Builder:

Number pad2 Number pad2

Choose Numbers and Punctuation

Upvotes: 0

Mikayel Aghasyan
Mikayel Aghasyan

Reputation: 225

[yourTextField setInputView:yourKeyPadView];

Upvotes: 3

Ramin
Ramin

Reputation: 13433

You can subclass UITextField and override canBecomeFirstResponder. Return NO and it will never put up a keyboard. However, you'll need to be in charge of handling touches so you can enable/disable your own keyboard. This may affect cut/copy/paste behavior so think about whether you really want to do this.

Upvotes: 2

Related Questions