问题
I have a custom Keyboard that gets displayed for a certain UITextField when I set the textField's inputView to my KeyboardView. The keyboard works fantastically well but it has become apparent that the keyboard will 'float' if the user has previously undocked the built in Apple Keyboard or indeed split it.
I have searched for many hours for a way to ensure my custom keyboard does not act like this and instead stays docked to the bottom of the screen regardless as to whether the user has previously undocked the built in Apple Keyboard.
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];
回答1:
You shouldn't do this, neither is there a way to do so.
You cannot override user settings with a custom keyboard, especially not the ones that can improve the accessiblity of a user interface.
You could include a warning in the tutorial that your keyboard works best while being locked to the bottom, but you must ask yourself the question whether this is good UX or not. I would say the latter.
来源:https://stackoverflow.com/questions/12837275/how-to-stop-my-custom-keyboard-from-floating-or-being-undocked-on-ipad