显示iPhone键盘 [英] Display the iPhone keyboard

查看:97
本文介绍了显示iPhone键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,UITextView似乎与在可滚动视图中有一个可滚动视图相关。

I've run into a problem with the UITextView that seems to be related to having a scrollable view within a scrollable view.

为了补救这一点,我想我会尝试写我自己的多行(但不可滚动)文本视图。给定核心图形方法和UITextInputTraits类,似乎这应该是可行的。我唯一不能弄清楚的是,它是否可能显示(和捕获事件)的系统范围的键盘。

In order to remedy this i thought i would attempt to write my own multiline (but not scrollable) text view. Given the core graphics methods, and the UITextInputTraits class it seems like this should be feasable. The only thing i cant figure out is wether or not its possible to display (and catch events) for the system wide keyboard.

使用SDK甚至可能使用SDK? / p>

Is this even possible using the SDK?

推荐答案

在类似的情况下,我做了一个隐藏的UITextField,并将其委托设置为你的类,适当的UITextFieldDelegate方法来拦截键被按下。

What I did in a similar situation, is made a hidden UITextField, and set its delegate to your class where you can implement the appropriate UITextFieldDelegate methods to intercept the key's pressed.

这样:

UITextField *myHiddenTextField = [[UITextField alloc] initWithFrame: cgRectZero()];
myHiddenTextField.delegate = self;
[myHiddenTextField becomeFirstResponder];

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//use string here for the text input
return false;
}

这篇关于显示iPhone键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆