iOS 9 iPad Keyboard get rid of “undo view”

2020-06-01 05:09发布

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.

2条回答
家丑人穷心不美
2楼-- · 2020-06-01 05:45

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.

查看更多
混吃等死
3楼-- · 2020-06-01 05:50

This is code in Objective-C:

if (@available(iOS 9.0, *)) {
    UITextInputAssistantItem* item = yourTextView.inputAssistantItem;
    item.leadingBarButtonGroups = @[];
    item.trailingBarButtonGroups = @[];
}
查看更多
登录 后发表回答