问题
I am trying to programmatically remove the keyboard shortcut bar that appears at the bottom of an iPad when an external keyboard is connected.
There are plenty of posts and answers with "solutions" to this, but none of them work with the latest iOS. The closest solution was such:
UITextInputAssistantItem* item = [self inputAssistantItem];
item.leadingBarButtonGroups = @[];
item.trailingBarButtonGroups = @[];
All this currently does is remove the buttons on the left side of the bar. And this does nothing also:
textField.autocorrectionType = UITextAutocorrectionTypeNo;
How can I "programmatically" remove this bar??
回答1:
Sorry for using swift code.
You can try my idea:
- change autocorrectionType of UITextField from .yes to no.
- Get inputAssistantItem and change leadingBarButtonGroups and trailingBarButtonGroups to empty.
Source code example:
tfSearchNameHiragana.autocorrectionType = .no
let shortcut: UITextInputAssistantItem? = tfSearchNameHiragana.inputAssistantItem
shortcut?.leadingBarButtonGroups = []
shortcut?.trailingBarButtonGroups = []
回答2:
From InterfaceBuilder, change Correction to No:
Or, from source:
item.autocorrectionType = .no
来源:https://stackoverflow.com/questions/60875062/programmatically-hide-keyboard-shortcut-bar-ios-13