swift - 在文本字段中快速进行 3D 触摸时关闭编辑菜单

标签 swift uitextview 3dtouch uimenucontroller

enter image description here

如何使用 swift 在文本字段中进行 3D 触摸点击时关闭此菜单

最佳答案

创建一个返回 false 的无案例,并在 3D 触摸启动时调用该案例,并在 3D 触摸结束时调用选择案例。

override public func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool
        {
            switch self.currentState {
            case .select:
                if action == #selector(select(_:)) || action == #selector(selectAll(_:))
                {
                    return true
                }
            case .copy:
                if action == #selector(copy(_:))
                {
                    return true
                }
            case .paste:
                if action == #selector(paste(_:)) || action == #selector(select(_:)) || action == #selector(selectAll(_:))
                {
                    return true
                }
            case .none:
                return false
            }
            return false
        }

关于swift - 在文本字段中快速进行 3D 触摸时关闭编辑菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46499704/

相关文章:

ios - 如何使用 Swift 从 CoreData sqlite 表中获取特定行数据

ios - 当 UIContextualAction 的标题为空时,应用程序在 "voice over"中崩溃 - iOS 11

swift - 不能下标 pfobject 类型的值

iphone - 在 IOS 7 中,UITextView offsetFromPosition : toPosition: always return 0 with arguments of UITextPositions returned from UITextView characterRangeAtPoint

ios - UITextView中触发超链接文本点击和普通文本点击

ios - 用属性字符串替换 UITextViews 文本

ios - 带有字符串 tel ://*#06# is returning nil in Swift 的 URL

ios - Quick Action (3D Touch) 后的启动周期

ios - 通过 3D Touch 使用压缩预览 View

ios - 在导航中使用 View Controller 添加 3D 触摸动态快速操作