Programmatically Hide Keyboard Shortcut Bar iOS 13

微笑、不失礼 提交于 2021-01-28 05:11:34

问题


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:

  1. change autocorrectionType of UITextField from .yes to no.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!