如何在不影响消息UIMenuItem的情况下禁用默认UIMenuItem?

时间:2017-04-13 09:47:12

标签: ios swift jsqmessagesviewcontroller

有一种方法可以禁用默认的UIMenuItem

enter image description here

不影响消息UIMenuItem? enter image description here

viewDidLoad中:

HDBox

2 个答案:

答案 0 :(得分:1)

在此处选择长按messageBubble时会出现的内容。

var cont = window.parent.document.getElementById('container');
cont.style.display='none';

然后选择所需项目后会发生什么,

override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {

    if (action == #selector(UIResponderStandardEditActions.copy(_:))) {

        if(messages[indexPath.row].isMediaMessage) {
            return false
        } else {
            return true
        }
    }
    if (action == #selector(UIResponderStandardEditActions.cut(_:))) {

        if(messages[indexPath.row].isMediaMessage) {
            return false
        } else {
            return false
        }
    }
    if (action == #selector(UIResponderStandardEditActions.paste(_:))) {

        if(messages[indexPath.row].isMediaMessage) {
            return false
        } else {
            return false
        }
    }

    if (action == #selector(UIResponderStandardEditActions.delete(_:))) {

        if(messages[indexPath.row].isMediaMessage) {
            return true
        } else {
            return true
        }
    }

    return super.canPerformAction(action, withSender: sender)
}

}

答案 1 :(得分:0)

使用

cell.textView.selectable = falsecellForRow方法