单击文本字段时添加UIKeyboard

时间:2012-03-20 16:01:16

标签: iphone objective-c cocoa-touch

当用户点击UITextField时,我需要弹出键盘。我知道这是自动完成的。但我需要的键盘应该有.com@标志。就像在iOS的Facebook应用程序中一样。

如何添加此键盘?它叫什么?

3 个答案:

答案 0 :(得分:3)

您可以在此处找到答案:Programmatically change UITextField Keyboard type

总结......

您可以通过执行以下操作来更改键盘类型:

[textField setKeyboardType:(TYPE)];

使用以下某项替换(TYPE)

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).

您正在寻找的那个(显示@和.com)是UIKeyboardTypeEmailAddress

答案 1 :(得分:1)

实施此

-(void)textFieldDidBeginEditing:(UITextField *)sender{
[textField setKeyboardType:UIKeyboardTypeEmailAddressL];
}

答案 2 :(得分:1)

如果您使用界面构建器创建了UITextField,请导航到属性检查器并将键盘更改为电子邮件地址。

如果您以编程方式创建它,请添加此

[yourTextField setKeyboardType:UIKeyboardTypeEmailAddress];

yourTextField.keyboardType=UIKeyboardTypeEmailAddress;