UITextField inputView displays undo, redo, paste buttons

回眸只為那壹抹淺笑 提交于 2020-12-29 05:21:45

问题


I have created a custom inputView for my UITextField. The view itself looks and functions great, but on the iPad I'm getting undo, redo, and paste buttons above my custom inputView. How do I remove those buttons? They don't have any functionality, but they should be removed.


回答1:


With Swift 3 and XCode 8 I was able to remove the bar by removing the two button groups on the text field input:

self.textField.inputAssistantItem.leadingBarButtonGroups.removeAll()
self.textField.inputAssistantItem.trailingBarButtonGroups.removeAll()



回答2:


// hide undo, redo, paste button bar for textfield input view
UITextInputAssistantItem* item = [your_textfield inputAssistantItem];
item.leadingBarButtonGroups = @[];
item.trailingBarButtonGroups = @[];

will hide the top bar for input view.

Reference:How to hide the shortcut bar in iOS9




回答3:


Try removing the inputAccessoryView:

self.textField.inputAccessoryView = nil;


来源:https://stackoverflow.com/questions/33487914/uitextfield-inputview-displays-undo-redo-paste-buttons

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