インチ
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)
}
そして、あなたがしたい項目を選択した後に何が起こるか、
override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
if (action == #selector(UIResponderStandardEditActions.delete(_:))) {
print("deleted")
print(indexPath.row)
let messageKey = messages[indexPath.row].keyID
print("messageKey")
print(messageKey!)
messages.remove(at: indexPath.row)
collectionView.reloadData()
}
if (action == #selector(UIResponderStandardEditActions.copy(_:))) {
// do stuff
}
}
}
あなたはコピーを無効にしたいん - などを削除しますか? – Jack
@Jackはい、無効にすることも可能Selectable –
'cellForRowメソッド'の 'cell.textView.selectable = false'を試してください – Jack