我想知道如何获取uitextview的键盘类型。 我能够通过使用textfield.keyboardtype获得uitextfield的键盘类型,但它似乎不适用于uitextview。 请帮助我解决这个问题。UITextView的键盘类型
在此先感谢。
我想知道如何获取uitextview的键盘类型。 我能够通过使用textfield.keyboardtype获得uitextfield的键盘类型,但它似乎不适用于uitextview。 请帮助我解决这个问题。UITextView的键盘类型
在此先感谢。
试试这个
UITextView *txvw = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 24, 20)];
txvw.keyboardType =UIKeyboardTypeURL;
和备用的键盘类型为
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).
如果你只是读的UITextView类的引用,它在键盘上一整节,并在那就是这样的文字:
“键盘本身的外观可以使用UITextInputTraits协议提供的属性进行自定义,文本视图对象实现此协议并支持它定义的属性。您可以使用这些属性来指定要显示的键盘类型(ASCII,数字,URL,电子邮件和其他)。您还可以配置键盘的基本文本输入行为,例如它是否支持自动大写和校正文本。“
所以这意味着UITextView采用UITextInputTraits协议,这意味着它响应每个必需的消息。要覆盖的方法,你就需要继承的UITextView,然后添加方法子类返回不同的键盘类型等
有关属性,你可以设置属性为其他响应者建议。
您可以像使用UITextField一样获取UITextView的keyboardType。
UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,320,30)];
[self.view addSubview:textView];
UIKeyboardType type = textView.keyboardType;
[textView release];
什么通过调用textview.keyboardType返回? – 2012-07-19 13:08:13