我不敢相信我还没有找到任何关于此的文档,但我想知道如何命令键盘激活并接收来自它的输入。我可以找到在编辑文本字段时操作弹出键盘的所有示例。谢谢
最佳答案
您还可以使用 UIKeyInput 协议(protocol)来请求键盘,而无需创建隐藏文本字段。
@interface My : UIViewController <UIKeyInput> ...
然后在实现中类似这样
// Methods which make the keyboard work
- (BOOL) hasText
{
return YES;
}
- (void)deleteBackward
{
[self handleBackspace];
}
- (void) insertText:(NSString* )text
{
int n = [text length];
int i;
for (i = 0; i < n; i++)
{
[self handleKey:[text characterAtIndex:i]];
}
}
- (BOOL) canBecomeFirstResponder
{
return YES;
}
// Methods to manage the appearance of the keyboard
- (void) summonKeyboard
{
[self becomeFirstResponder];
}
- (void) dismissKeyboard
{
[self resignFirstResponder];
}
关于iphone - 激活 iPhone 键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3098583/