dor*_*kon 4 objective-c uiview ipad ios
我有一些iPad应用程序,用户将使用触摸屏或蓝牙键盘导航.我有一些隐藏的textView,它是焦点(第一响应者),在这里我检测从键盘输入的内容.
但是,当我断开键盘时,我遇到了问题,出现了虚拟键盘.
我可以检查蓝牙键盘是否已连接,以及在viewDidLoad中设置或终止第一响应者?
要么
我有通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear:) name:UIKeyboardWillShowNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
触发keyboardWillAppear时,我可以在某种程度上隐藏键盘吗? 我试过[textView resignFirstResponder],但没有成功:|
你可以使用performSelector:为此.
- (void)hideKeyboard:(UITextView *)textView {
[textView resignFirstResponder];
}
- (void)keyboardWillAppear:(NSNotification *)notification {
UITextView *textView = (UITextView *)[self.view viewWithTag:TEXTVIEW_TAG];
[self performSelector:@selector(hideKeyboard:) withObject:textView];
}
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear:) name:UIKeyboardWillShowNotification object:nil];
}
Run Code Online (Sandbox Code Playgroud)
您可以将inputView设置为透明视图:
UIView *emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
emptyView.backgroundColor = [UIColor clearColor];
textView.inputView = emptyView;
Run Code Online (Sandbox Code Playgroud)
从理论上讲,它会将屏幕键盘设置为空视图,因此不可见.如果它不接受没有框架的视图,那么尝试将宽度和高度碰撞到1.它不会影响外部键盘; 它只是不会出现在设备上.
| 归档时间: |
|
| 查看次数: |
581 次 |
| 最近记录: |