iOS 9 iPad Keyboard get rid of “undo view”

不问归期 提交于 2019-12-04 10:11:48

问题


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

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.


回答1:


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.




回答2:


This is code in Objective-C:

if (@available(iOS 9.0, *)) {
    UITextInputAssistantItem* item = yourTextView.inputAssistantItem;
    item.leadingBarButtonGroups = @[];
    item.trailingBarButtonGroups = @[];
}


来源:https://stackoverflow.com/questions/32670035/ios-9-ipad-keyboard-get-rid-of-undo-view

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