没有textview的iphone键盘 [英] iphone keyboard without textview
问题描述
是否可以在没有textview的iPhone应用程序中调出键盘?或者我必须有一个看不见的textview?
is it possible to bring up the keyboard in an iphone app without a textview? or will i have to have an invisible textview?
如果是这样,你如何以编程方式创建一个textview然后调出键盘(用户不必点击textview )?我可以找到的唯一示例使用界面构建器..
if so, how do you programatically create a textview and then bring up the keyboard (without the user having to tap the textview)? the only examples i can find use interface builder..
推荐答案
显示键盘的唯一(有效)方法是作为第一响应者的textfield。
您可以隐藏它并通过在隐藏文本字段上调用 becomeFirstResponder
以编程方式使其成为第一响应者。
The only (valid) way to show the keyboard is to have a textfield that is first responder.
You can hide it and make it first responder programmatically by calling becomeFirstResponder
on the hidden textfield.
你可以通过这样的方式以编程方式创建UITextView(假设aRect和视图存在)
You can create a UITextView programmatically by doing something like this (assume aRect and view exist)
var textView = [[[UITextView alloc] initWithFrame:aRect] autorelease];
[view addSubview:textView];
[textView becomeFirstResponder];
这篇关于没有textview的iphone键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!