以编程方式取消对接键盘? [英] Undock Keyboard Programmatically?

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

问题描述

我想我们不可能以编程方式取消对接虚拟键盘.当然,如果可能的话,我想知道如何.我还以为我们不可能以编程方式打开 Split Keyboard (拆分键盘)开关(常规>键盘).

I suppose that it is not possible for us to programmatically undock the virtual keyboard. If possible, of course, I would like to know how. I also suppose that it is not possible for us to turn the Split Keyboard switch (General > Keyboard) on programmatically.

无论如何,我的情况如下.我在顶部有一个tableview控件,在其下面有一个textview控件,在底部有一个工具栏控件. textview控件是可编辑的.因此,如果用户触摸它,虚拟键盘将打开,并覆盖底部的工具栏控件.并且此键盘将覆盖工具栏控件上的按钮.我该怎么做,以便用户可以访问这些按钮?我确实已经通过 UIKeyboardDidShowNotification UIKeyboardWillHideNotification 准备了通知,以便我可以告诉用户何时触摸了textview控件.将工具栏控件放在最底部以外的其他位置吗?我希望我不必这样做.也许在键盘向上的同时向上移动整个视图?我想我可以做到.

Anyway, my situation is the following. I have a tableview control at the top and a textview control right below it with a toolbar control at the bottom. The textview control is editable. So if a user touches it, the virtual keyboard will open, covering the bottom toolbar control. And this keyboard will cover the buttons on the toolbar control. What can I do so that a user can have access to these buttons? I do have a notification ready with UIKeyboardDidShowNotification and UIKeyboardWillHideNotification so that I can tell when a user touches the textview control. Place the toolbar control somewhere else other than at the very bottom? I hope I don't have to do that. Maybe, move the entire view way up while the keyboard is up? I think I can do that.

谢谢您的建议.

推荐答案

我刚刚决定在打开虚拟键盘时将整个框架向上移动.看起来还不错.

I've just decided to move the entire frame upwards when the virtual keyboard is open. It doesn't look bad.

- (void)keyboardWasShown:(NSNotification*)aNotification {
// NSLog(@"It's appeared.");

keyboardup = true;
[self.view setFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y-300,self.view.frame.size.width,self.view.frame.size.height)];

}

- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
// NSLog(@"It's gone");

keyboardup = false;
    [self.view setFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y+300,self.view.frame.size.width,self.view.frame.size.height)];

}

- (void)keyboardCallingNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWasShown:)
                                             name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWillBeHidden:)
                                             name:UIKeyboardWillHideNotification object:nil];
}

这篇关于以编程方式取消对接键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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