0

There is delegate method for textfeilds to display the number pad . Similar to that I want to display it when clicking a button.Is it possible?? Since my app deals with phone calls,I want to make a call to the number which is not stored in address book...

Icoder
  • 330
  • 3
  • 25

1 Answers1

0

I'm assuming you mean UITextField. It conforms to the UITextInputTraits protocol so you can set its keyboardType property to UIKeyboardTypePhonePad.

Example:

UITextField *textField = [[UITextField alloc] init];
textField.keyboardType = UIKeyboardTypePhonePad;
...
[textField becomeFirstResponder];

Reference: UITextField Class Reference

The appearance of the keyboard itself can be customized using the properties provided by the UITextInputTraits protocol. Text field objects implement this protocol and support the properties it defines. You can use these properties to specify the type of keyboard (ASCII, Numbers, URL, Email, and others) to display. You can also configure the basic text entry behavior of the keyboard, such as whether it supports automatic capitalization and correction of the text.

Cedric Han
  • 174
  • 3
  • thanks... Bt my question is nt abt txtfeild.I want to display numpad by means of button click – Icoder Aug 26 '11 at 06:59
  • 1
    Oh. You can use a hidden `UITextField` with the keyboardType property set, and your button's action should invoke `[textField becomeFirstResponder]`. This will display the numeric keypad. Then using your `UITextFieldDelegate`, you can read out the values from the textfield as the value changes. – Cedric Han Aug 26 '11 at 07:03