我正在制作一个需要拨号盘才能从应用程序拨打电话号码的应用程序。 iphone拨号盘很棒,但无法在我的应用程序中模仿它。 我想到的唯一方法就是为每个数字设置单独的按钮,但它看起来与原来的拨号盘非常不同。
答案 0 :(得分:2)
如果您有UITextField
,则可以设置keyboardType
属性,以便在用户关注时显示数字键盘。
UITextField *textField;
textfield.keyboardType = UIKeyboardTypePhonePad;
keyboardType
可以是enum
:
typedef enum {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
} UIKeyboardType;