-1

我想我们不可能以编程方式解除虚拟键盘的连接。如果可能的话,当然,我想知道如何。我还认为我们不可能以编程方式打开拆分键盘开关(常规 > 键盘)。

反正我的情况如下。我在顶部有一个 tableview 控件,在它下面有一个 textview 控件,在底部有一个工具栏控件。textview 控件是可编辑的。因此,如果用户触摸它,虚拟键盘将打开,覆盖底部工具栏控件。这个键盘将覆盖工具栏控件上的按钮。我该怎么做才能让用户可以访问这些按钮?我确实准备好了UIKeyboardDidShowNotificationUIKeyboardWillHideNotification的通知,这样我就可以知道用户何时触摸 textview 控件。将工具栏控件放置在最底部以外的其他位置?我希望我不必那样做。也许,在键盘启动时将整个视图向上移动?我想我可以做到。

感谢您的意见。

4

1 回答 1

-1

我刚刚决定在虚拟键盘打开时向上移动整个框架。它看起来并不坏。

- (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];
}
于 2013-03-01T06:07:28.353 回答