消息多选
IMKit 会话页面支持长按消息多选功能。
效果展示
自定义多选
您可参考 SealTalk 开源项目 中 RCDChatViewController
的 messageSelectionToolbar
操作实例。
设置多选状态
通过设置会话页面 RCConversationViewController
的 allowsMessageCellSelection
属性可以切换多选状态和初始状态。如果为 YES,消息 cell 会变为多选样式;如果为 NO,页面恢复初始状态。
Objective C
@property (nonatomic, assign) BOOL allowsMessageCellSelection;
如果需要修改 SDK 内置消息是否允许多选,可在会话页面重写 willDisplayMessageCell:
方法,修改消息 cell 的 allowsSelection
属性。自定义消息如果允许多选,也可以设置此属性。
Objective C
- (void)willDisplayMessageCell:(RCMessageBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath;
获取已选择的消息
只有在会话页面 RCConversationViewController
的 allowsMessageCellSelection
为 YES 时,selectedMessages
才有有效值。
Objective C
@property(nonatomic, strong, readonly) NSArray<RCMessageModel *> *selectedMessages;
自定义底部视图。
进入多选状态后,页面底部会出现的工具视图。您可以添加对多选消息的操作事件,如转发、收藏等。您可以在会话页面 RCConversationViewController
的 viewDidLoad
中通过给 messageSelectionToolbar
添加 UIBarButtonItem
的方式添加事件。
Objective C
@property(nonatomic, strong) UIToolbar *messageSelectionToolbar;