如何在iPad上隐藏快速键盘工具栏?

时间:2016-04-27 11:23:32

标签: ios objective-c swift keyboard

如何在iPad上隐藏快速键盘工具栏?

enter image description here

以下代码无效:

textField.autocorrectionType = UITextAutocorrectionTypeNo;

3 个答案:

答案 0 :(得分:8)

将此代码放在 viewDidLoad

yourTextFieldName.autocorrectionType = UITextAutocorrectionTypeNo;
UITextInputAssistantItem* shortcut = [yourTextFieldName inputAssistantItem];
shortcut.leadingBarButtonGroups = @[];
shortcut.trailingBarButtonGroups = @[];

<强>夫特

    yourTextFieldName.autocorrectionType = .No
    let shortcut : UITextInputAssistantItem = yourTextFieldName.inputAssistantItem
    shortcut.leadingBarButtonGroups = []
    shortcut.trailingBarButtonGroups = []

<强> swift3

 yourTextFieldName.autocorrectionType = .no
 var shortcut: UITextInputAssistantItem? =     yourTextFieldName.inputAssistantItem()
shortcut?.leadingBarButtonGroups = []
shortcut?.trailingBarButtonGroups = []

for reference

答案 1 :(得分:1)

How to hide the shortcut bar in iOS9

你试过这个吗?你所做的只是禁用文本提议,而不是撤消/重做/粘贴...东西。

答案 2 :(得分:0)

  

要完全隐藏快捷方式,请将leadingBarButtonGroups和trailingBarButtonGroups属性设置为nil。这样做只隐藏快捷方式,不会隐藏输入建议。要隐藏输入建议,还必须将显示键盘的响应者的autocorrectionType属性设置为UITextAutocorrectionTypeNo。

<editorView>.autocorrectionType = UITextAutocorrectionTypeNo;
UITextInputAssistantItem* shortcut = [<editorView> inputAssistantItem];
shortcut.leadingBarButtonGroups = @[];
shortcut.trailingBarButtonGroups = @[];