gpt4 book ai didi

ios - 如何以编程方式隐藏键盘剪贴板?

转载 作者:行者123 更新时间:2023-12-01 15:56:43 24 4
gpt4 key购买 nike

每次我点击 UItextview 这个剪贴板都会出现在底部,我如何以编程方式禁用它?

enter image description here

最佳答案

iPhone 上,您只需设置 autocorrectionType = .no 即可完全移除键盘上方的栏。

iPad 上,您应该首先添加这些扩展:

extension UITextView {
func hideSuggestions() {
// Removes suggestions only
autocorrectionType = .no
//Removes Undo, Redo, Copy & Paste options
removeUndoRedoOptions()
}
}

extension UITextField {
func hideSuggestions() {
// Removes suggestions only
autocorrectionType = .no
//Removes Undo, Redo, Copy & Paste options
removeUndoRedoOptions()
}
}

extension UIResponder {
func removeUndoRedoOptions() {
//Removes Undo, Redo, Copy & Paste options
inputAssistantItem.leadingBarButtonGroups = []
inputAssistantItem.trailingBarButtonGroups = []
}
}

之前:
Before

  1. 要仅删除撤消、重做、复制和粘贴选项但在键盘顶部显示建议,调用函数 func removeUndoRedoOptions() After

  2. 要完全删除建议栏以及撤消、重做、复制和粘贴选项,请调用函数 func hideSuggestions() After

关于ios - 如何以编程方式隐藏键盘剪贴板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63805395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com