17

我有一个自定义键盘,当我将 textField 的 inputView 设置为我的 KeyboardView 时,它会为某个 UITextField 显示。键盘工作得非常好,但很明显,如果用户之前取消了内置 Apple 键盘或确实拆分了它,键盘将“浮动”。

我已经搜索了好几个小时,以确保我的自定义键盘不会像这样运行,而是保持停靠在屏幕底部,无论用户之前是否取消了内置的 Apple 键盘。

self.keyboardInputView = [[[KeyboardInputViewController_iPad alloc]
                            initWithNibName:@"KeyboardInputViewController_iPad"
                            bundle:[NSBundle mainBundle]] autorelease];
self.keyboardInputView.delegate = self;                
self.keyboardInputView.keyboardTextField = myTextField;
myTextField.inputView = self.keyboardInputView.view;
[myTextField becomeFirstResponder];
4

1 回答 1

0

你不应该这样做,也没有办法这样做。

您不能使用自定义键盘覆盖用户设置,尤其是那些可以提高用户界面可访问性的设置。

可以在教程中包含一个警告,即您的键盘在锁定到底部时效果最佳,但您必须问自己这个问题是否是好的用户体验。我会说后者。

于 2017-09-12T14:06:21.520 回答