Skip to main content

Message Multi-Selection

IMKit's chat UI supports long-press multi-selection for messages.

Demo

alt(width=250) alt(width=250)

Custom Multi-Selection

Refer to the messageSelectionToolbar implementation in RCDChatViewController from the SealTalk open-source project.

Set Multi-Selection Mode

Toggle between multi-selection and default modes by modifying the allowsMessageCellSelection property of RCConversationViewController. Set to YES to enable multi-selection styling for message cells; set to NO to restore the default state.

@property (nonatomic, assign) BOOL allowsMessageCellSelection;

To modify whether built-in messages support multi-selection, override the willDisplayMessageCell: method in the chat UI and adjust the cell's allowsSelection property. Custom messages can also enable multi-selection by setting this property.

- (void)willDisplayMessageCell:(RCMessageBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath;

Retrieve Selected Messages

The selectedMessages property only returns valid values when allowsMessageCellSelection is set to YES in RCConversationViewController.

@property(nonatomic, strong, readonly) NSArray<RCMessageModel *> *selectedMessages;

Customize Bottom Toolbar

When multi-selection is active, a toolbar appears at the bottom. Add actions like forward or favorite for selected messages by including UIBarButtonItem elements in the messageSelectionToolbar during viewDidLoad of RCConversationViewController.

@property(nonatomic, strong) UIToolbar *messageSelectionToolbar;