【问题标题】:Close edit menu when 3D touch in textfield swift快速在文本字段中进行 3D 触摸时关闭编辑菜单
【发布时间】:2018-03-12 00:01:38
【问题描述】:

当使用 swift 在文本文件中单击 3D 触摸时如何关闭此菜单

【问题讨论】:

  • 什么意思?
  • 我的意思是当长按这个菜单打开但是当 3d touch 我想关闭这个菜单。
  • 所以你不想在长按时显示这个菜单,这是你想做的吗?
  • 不,我想在长按时显示此菜单,但我想在 3D 触摸按下时关闭。
  • 强制触摸时不会自动关闭吗?

标签: swift uitextview 3dtouch uimenucontroller


【解决方案1】:

创建一个返回 false 的 none 案例,并在 3D touch 开始时调用该案例,并在 3D touch 结束时调用 select 案例。

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
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多