views:

742

answers:

1

Hello everyone, and thanks for your responses in advance.

I have been looking around for the possibility of having a 10-key, numeric only, input available when a user clicks on certain fields that do not require the use of the full size keyboard.

I know that popovers can properly display custom types of input, but does anyone know if there is a way for a standard 10-keypad to display in a popover? And if so, can you point me in the right direction.

Again, thanks in advance.

-Rick

+5  A: 

You don't need to use popover if you try to enter numeric value in a UITextField/UITextView. You can replace the keyboard by your own view. You just do : [yourTextField setInputView:myInputView];

You can have a look at KeyboardAccessory sample from apple http://developer.apple.com/iphone/library/samplecode/KeyboardAccessory/Introduction/Intro.html In this example, they provide an accessory view to the input view but if you modify the code and set inputView instead of inputViewAccessory, you should be able to do what you need.

If you use a UITextView, you can append text where the carret is with the following code:

NSMutableString *text = [textView.text mutableCopy];
NSRange selectedRange = textView.selectedRange;
[text replaceCharactersInRange:selectedRange withString:@"\n"];
textView.text = text;

If you use a UITextField, it seems you can only append text at the end of the string (no mean to retrieve carret position).

olipion