最新3.5.2IOS的sdk,遇到一个无敌bug,大神解惑
工程中,写了自定义的消息cell,按照官方示例代码写的。现在自定义消息可以发送了,但是只要我发送过自定义消息,接着连续发送4-5条文字消息时,莫名其妙的会有一条文字消息显示为自定会消息,实在找不出问题,困扰很久了,哪位大神帮忙解惑下,谢谢了!
发送消息的代码:
var info = SendLinkInfo()
info.imgUrl = item.previewImageName
info.id = item.id
info.address = item.townName
info.time = item.createTime.showTime()
info.userId = item.userId
info.title = item.title
info.type = item.type
let msg=EMMessage.init(conversationID: self.conversation.conversationId, from: EMClient.shared()?.currentUsername, to: self.conversation.conversationId, body: EMTextMessageBody.init(text: ""), ext: ["is_trade":true,"trade":info.toJSONString()!])
self.send(msg, isNeedUploadFile: true)
其他代码:
func messageViewController(_ tableView: UITableView!, cellFor messageModel: IMessageModel!) -> UITableViewCell! {
if let msg = messageModel.message.ext ,let _ = msg["trade"] {
let cellID:String = ChatLinkCell.cellIdentifier(withModel: messageModel)
var cell:ChatLinkCell? = tableView.dequeueReusableCell(withIdentifier: cellID) as? ChatLinkCell
if cell == nil {
cell = ChatLinkCell(style: .default, reuseIdentifier: cellID, model: messageModel)
}
cell?.hasRead.isHidden = true
cell?.model = messageModel
return cell
}
return nil
}
发送消息的代码:
var info = SendLinkInfo()
info.imgUrl = item.previewImageName
info.id = item.id
info.address = item.townName
info.time = item.createTime.showTime()
info.userId = item.userId
info.title = item.title
info.type = item.type
let msg=EMMessage.init(conversationID: self.conversation.conversationId, from: EMClient.shared()?.currentUsername, to: self.conversation.conversationId, body: EMTextMessageBody.init(text: ""), ext: ["is_trade":true,"trade":info.toJSONString()!])
self.send(msg, isNeedUploadFile: true)
其他代码:
func messageViewController(_ tableView: UITableView!, cellFor messageModel: IMessageModel!) -> UITableViewCell! {
if let msg = messageModel.message.ext ,let _ = msg["trade"] {
let cellID:String = ChatLinkCell.cellIdentifier(withModel: messageModel)
var cell:ChatLinkCell? = tableView.dequeueReusableCell(withIdentifier: cellID) as? ChatLinkCell
if cell == nil {
cell = ChatLinkCell(style: .default, reuseIdentifier: cellID, model: messageModel)
}
cell?.hasRead.isHidden = true
cell?.model = messageModel
return cell
}
return nil
}
没有找到相关结果
已邀请:
1 个回复
shuijilove
视频:https://pan.baidu.com/s/1EFyyNdWhBTqEkIqy0mpkfA