Search code examples
swiftkeyboardios9

iOS 9 iPad Keyboard get rid of "undo view"


How is it possible to get rid of this annoying "undo view" shown on the iPad in iOS 9. enter image description here

Below is my own keyboard, above my accessory view. (just for testing purposes in this ugly color). Can someone please tell me how to remove it? Thanks in advance.


Solution

  • For Swift 2.0, You can place this code in viewDidLoad and it will work like a charm.

    if #available(iOS 9.0, *) {
        let item = yourTextView.inputAssistantItem
        item.leadingBarButtonGroups = []
        item.trailingBarButtonGroups = []
    } else {
        // Fallback on earlier versions
    }
    

    In Swift 3.0 and 4.0

    youtTextField.inputAssistantItem.leadingBarButtonGroups.removeAll()
    yourTextField.inputAssistantItem.trailingBarButtonGroups.removeAll()
    

    However the best way to use this is to subclass a UITextfield and use the above code in the init() phase. Or to create an extension Instead of using it in the viewDidLoad for each and every textField.