页面事件监听
监听会话列表页面事件
您可以设置会话列表操作监听,实现自定义需求。以下列出了 RCConversationListViewController.h 提供的常用事件,您也可以直接参考 IMKit 源码,查看所有事件。
重写监听方法需要注意调用重写方法的 super
方法,避免影响 IMKit SDK 原有的逻辑。
即将显示会话 Cell
您可以重写 RCConversationListViewController 的 willDisplayConversationTableCell:
方法修改会话 Cell 的一些显示属性,如对会话列表自带 Cell 样式如字体颜色,字体大小进行修改。
不建议修改 Cell 的布局。如果对 UI 比较高的定制需求,建议自定义会话列表中的会话 Cell。
接口原型
- (void)willDisplayConversationTableCell:(RCConversationBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath;
参数说明
参数 | 类型 | 说明 |
---|---|---|
cell | RCConversationBaseCell | 即将显示的 Cell |
indexPath | NSIndexPath | 该 Cell 对应的会话 Cell 数据模型在数据源中的索引值 |
点击会话 Cell
重写 RCConversationListViewController 的 onSelectedTableRow:
方法,跳转到您自定义的会话页面。
接口原型
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
conversationModel:(RCConversationModel *)model
atIndexPath:(NSIndexPath *)indexPath;
参数说明
参数 | 类型 | 说明 |
---|---|---|
conversationModelType | RCConversationModelType | 当前点击的会话的 Model 类型 |
model | RCConversationModel | 当前点击的会话的 Model |
indexPath | NSIndexPath | 当前会话在列表数据源中的索引值 |
点击会话列表头像
会话列表中的每个会话项目上均会显示一个头像图标,即会话头像(不是聊天页面内中消息列表中的头像)。单聊会话显示对方用户头像,群聊会话显示群组头像,聚合会话显示默认头像或应用程序主动设置的头像。
您可以重写 RCConversationListViewController 的 didTapCellPortrait:
方法,自定义处理点击头像事件。
接口原型
- (void)didTapCellPortrait:(RCConversationModel *)model;
参数说明
参数 | 类型 | 说明 |
---|---|---|
model | RCConversationModel | 会话 Cell 的数据模型 |
长按会话列表头像
会话列表中的每个会话项目上均会显示一个头像图标,即会话头像(不是聊天页面内中消息列表中的头像)。单聊会话显示对方用户头像,群聊会话显示群组头像,聚合会话显示默认头像或应用程序主动设置的头像。
您可以重写 RCConversationListViewController 的 didLongPressCellPortrait:
方法,自定义处理长按会话列表头像事件。
接口原型
- (void)didLongPressCellPortrait:(RCConversationModel *)model;
参数说明
参数 | 类型 | 说明 |
---|---|---|
model | RCConversationModel | 会话 Cell 的数据模型 |
删除会话
您可以重写 RCConversationListViewController 的 didDeleteConversationCell:
方法,自定义处理删除会话事件。
接口原型
- (void)didDeleteConversationCell:(RCConversationModel *)model;
参数说明
参数 | 类型 | 说明 |
---|---|---|
model | RCConversationModel | 会话 Cell 的数据模型 |
即将加载数据源
您可以重写 RCConversationListViewController 的 willReloadTableData:
方法,可修改、添加、删除数据源的元素来定制显示的内容,会话列表会根据您返回的修改后的数据源进行显示。数据源中存放的元素为会话 Cell 的数据模型,即 RCConversationModel
对象。
接口原型
- (NSMutableArray *)willReloadTableData:(NSMutableArray *)dataSource;
参数说明
参数 | 类型 | 说明 |
---|---|---|
dataSource | NSMutableArray | 即将加载的增量数据源 |
dataSource 为增量数据,conversationListDataSource += dataSource
。如果需要更改全量数据的内容,可以更改 conversationListDataSource
。
即将更新未读消息数
当收到消息或删除会话时,会触发此回调。你可以重写 RCConversationListViewController 的 notifyUpdateUnreadMessageCount
方法,可以执行未读消息数相关的操作。
接口原型
- (void)notifyUpdateUnreadMessageCount;
该方法在非主线程回调,如果想在本方法中操作 UI,请手动切换到主线程。