
IM即时通讯
安全可靠、全球互通

实时音视频
流畅稳定、省钱省力
回答:
1. 在 Cell 即将显示的回调函数中,判断是否可以设置“已读”或“未读”
2. 如果可以设置,在对应的 UI 中根据消息发送状态设置,并刷新 UI。
1. 创建一个数组,设置不需要显示消息发送状态的消息类型,用于排除使用。
*设置属性
/*! 关闭显示已读未读标示的消息类型 @discussion 存放消息类型的 ObjectName, 开启 enabledReadReceiptConversationTypeList 后需要关闭显示已读未读标示的消息类型,这些消息话类型的消息在会话页面和会话列表不显示已读和未读标示。 */ @property(nonatomic, copy) NSArray<NSString *> *hideReadStatusMessageTypeList;
*创建数组
- (void)viewDidLoad { [super viewDidLoad]; self.hideReadStatusMessageTypeList = @[@"RC:VCAccept", @"RC:VCHangup", @"RC:VCInvite", @"RC:VCModifyMedia", @"RC:VCModifyMem", @"RC:VCRinging", @"RC:VCSummary", @"RC:RcNtf", @"RC:RLStart", @"RC:RLEnd", @"RC:RLJoin", @"RC:RLQuit", @"RCJrmf:RpMsg", @"RC:RCSummary", @"RC:RCRequest", @"RC:RCRing", @"RC:RCAccept", @"RC:RCHangUp", @"RC:RCInvite" , @"RC:RCConfig"]; }
2. 在 cell 即将显示的回调函数中,判断设置条件,在满足条件时,修改并刷新 UI
- (void)willDisplayConversationTableCell:(RCConversationBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath { RCConversationCell *conversationCell = (RCConversationCell *)cell; RCConversationModel *model = self.conversationListDataSource[indexPath.row]; //判断可以设置“未读”和“已读”的情况 if ([conversationCell isKindOfClass:[RCConversationCell class]] && model.draft.length == 0 && model.lastestMessageId > 0 && model.lastestMessageDirection == MessageDirection_SEND && (model.sentStatus == SentStatus_SENT || model.sentStatus == SentStatus_READ) && ![self.hideReadStatusMessageTypeList containsObject:[[model.lastestMessage class] getObjectName]]) { //显示对应的 Label conversationCell.detailContentView.hightlineLabel.hidden = NO; //默认设置为“未读” NSString *prefixName = @"[未读]"; conversationCell.detailContentView.hightlineLabel.textColor = [UIColor blueColor]; //判断如果发送状态是 SentStatus_READ,显示“画已读” if (model.sentStatus == SentStatus_READ) { prefixName = @"[已读]"; conversationCell.detailContentView.hightlineLabel.textColor = [UIColor grayColor]; } //不在显示 SDK 默认的已读图标 conversationCell.statusView.messageReadStatusView.image = nil; //赋值并刷新 UI conversationCell.detailContentView.hightlineLabel.text = prefixName; [conversationCell.detailContentView updateLayout]; } }