【发布时间】:2018-02-01 15:40:02
【问题描述】:
我正在将 JSQMessage 用于聊天应用程序。长按我可以 显示默认菜单选项(复制和删除)
现在的挑战是在菜单中添加另一个选项。任何帮助都会 赞赏。
默认菜单选项的代码是
override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
super.collectionView(collectionView, shouldShowMenuForItemAt: indexPath)
return true;
}
override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
let message = messageList[indexPath.item]
switch action.description {
case quickChatOptionDelete:
// you can only delete your sent messages
if message.senderId == strMemberID {
return true
} else {
return false
}
case quickChatOptionCopy:
return true
case quickChatOptionUserList:
return true
default:
return false
}
}
override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
let message = messageList[indexPath.item]
switch action.description {
case quickChatOptionDelete:
if message.senderId == strMemberID {
deleteMessage(messageId:message.messageId!)
}
break
case quickChatOptionCopy: break
case quickChatOptionUserList:
print("list")
break
default: break
// do nothing
}
}
【问题讨论】:
标签: ios iphone swift chat jsqmessagesviewcontroller