TUIMessageController Class Reference

Inherits from UITableViewController
Declared in TUIMessageController.h
TUIMessageController.m

Overview

腾讯云 TUIKit 【模块名称】TUIMessageController 【功能说明】消息控制器,负责实现消息的接收、发送、显示等一系列业务逻辑。 本类提供了接收/显示新消息、显示/隐藏菜单、点击消息头像等交互操作的回调接口。 同时本类提供了图像、视频、文件信息的发送功能,直接整合调用了 IM SDK 实现发送功能。

Other Methods

  delegate

执行 TMessageControllerDelegate 协议的委托

@property (nonatomic, weak) id<TMessageControllerDelegate> delegate

Declared In

TUIMessageController.h

– sendMessage:

发送消息 本函数整合调用了 IM SDK 的发送接口,可以轻松接入 SDK。

- (void)sendMessage:(TUIMessageCellData *)msg

Parameters

msg

消息单元数据

Declared In

TUIMessageController.h

– scrollToBottom:

滚动至底部 通过对 tableView 进行设置,使当前视图滚动至底部。 建议在需要返回至消息视图底部或者需要浏览最新信息时调用,比如每次发送消息、接收消息、撤回消息、删除消息时。 本函数的实现调用了 tableView 的滑动函数:

[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[uiMsgs](#//api/name/uiMsgs).count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:animate];

其中第一个参数出现的 uiMsgs,即当前消息控制器中已接收到并展示的消息数组。

- (void)scrollToBottom:(BOOL)animate

Parameters

animate

动画标志位。YES:启用动画;NO:禁用动画。

Declared In

TUIMessageController.h

– setConversation:

设置会话

- (void)setConversation:(TIMConversation *)conversation

Parameters

conversation

需要设置的会话

Declared In

TUIMessageController.h

– sendImageMessage:

发送图像信息 本函数整合调用了 IM SDK 的发送接口,可以轻松接入 SDK。 1、首先将图片压缩并生成相关路径。 2、将压缩后的图片保存在本地的刚刚生成的路径中。 3、创建 TUIImageMessageCellData 实例,并将 path 和压缩后图片的体积存放于 TUIImageMessageCellData 中。 4、调用已封装好的 sendMessage 函数将 cellData 进行发送。 5、上传进度由在 NSNotificationCenter 创建的上传进度监听事件进行监听与更新。

- (void)sendImageMessage:(UIImage *)image

Parameters

image

需要发送的图像

Declared In

TUIMessageController.h

– sendVideoMessage:

发送视频信息 本函数整合调用了 IM SDK 的发送接口,可以轻松接入 SDK。 1、通过视频 URL 获取视频数据,同时生成相关本地路径。 2、将视频数据存放于生成的本地路径中。 3、计算出视频的时长与数据体积等相关信息。 4、然后从视频中提取出封面(snapshot),同时生成相关本地路径并存放其中。 5、创建 TUIVideoMessageCellData,并将视频、路径、体积、时长、封面、上传进度信息等存放其中。 6、调用已封装好的 sendMessage 函数将 cellData 进行发送。 7、上传进度由在 NSNotificationCenter 创建的上传进度监听事件进行监听与更新。

- (void)sendVideoMessage:(NSURL *)url

Parameters

url

需要发送的视频的url

Declared In

TUIMessageController.h

– sendFileMessage:

发送文件信息 本函数整合调用了 IM SDK 的发送接口,可以轻松接入 SDK。 1、通过文件 URL 获取文件数据,同时根据文件名生成本地路径。 2、将文件数据存放于生成的本地路径中。 3、创建 TUIFileMessageCellData,并将文件路径、大小、路径、上传进度等信息存放其中。 4、调用已封装好的 sendMessage 函数将 cellData 进行发送。 5、上传进度由在 NSNotificationCenter 创建的上传进度监听事件进行监听与更新。

- (void)sendFileMessage:(NSURL *)url

Parameters

url

需要发送的文件url

Declared In

TUIMessageController.h

Other Methods

– viewDidLoad

- (void)viewDidLoad

– dealloc

- (void)dealloc

– viewWillAppear:

- (void)viewWillAppear:(BOOL)animated

– viewWillDisappear:

- (void)viewWillDisappear:(BOOL)animated

– readedReport

- (void)readedReport

– setupViews

- (void)setupViews

– loadMessage

- (void)loadMessage

– onNewMessage:

- (void)onNewMessage:(NSNotification *)notification

– onRevokeMessage:

- (void)onRevokeMessage:(NSNotification *)notification

– onUploadMessage:

- (void)onUploadMessage:(NSNotification *)notification

– transUIMsgFromIMMsg:

- (NSMutableArray *)transUIMsgFromIMMsg:(NSArray *)msgs

– tableView:willDisplayCell:forRowAtIndexPath:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

– tableView:numberOfRowsInSection:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

– tableView:heightForRowAtIndexPath:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

– tableView:cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

– tableView:didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

– didTapViewController

- (void)didTapViewController

– changeMsg:status:

- (void)changeMsg:(TUIMessageCellData *)msg status:(TMsgStatus)status

– transIMMsgFromUIMsg:

- (TIMMessage *)transIMMsgFromUIMsg:(TUIMessageCellData *)data

– transSystemMsgFromDate:

- (TUISystemMessageCellData *)transSystemMsgFromDate:(NSDate *)date

– scrollViewDidScroll:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

– scrollViewDidEndDecelerating:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

– onSelectMessage:

- (void)onSelectMessage:(TUIMessageCell *)cell

– onLongPressMessage:

- (void)onLongPressMessage:(TUIMessageCell *)cell

– onRetryMessage:

- (void)onRetryMessage:(TUIMessageCell *)cell

– onSelectMessageAvatar:

- (void)onSelectMessageAvatar:(TUIMessageCell *)cell

– canPerformAction:withSender:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

– canBecomeFirstResponder

- (BOOL)canBecomeFirstResponder

– onDelete:

- (void)onDelete:(id)sender

– menuDidHide:

- (void)menuDidHide:(NSNotification *)notification

– onCopyMsg:

- (void)onCopyMsg:(id)sender

– onRevoke:

- (void)onRevoke:(id)sender

– onReSend:

- (void)onReSend:(id)sender

– revokeMsg:

- (void)revokeMsg:(TUIMessageCellData *)msg

– playVoiceMessage:

- (void)playVoiceMessage:(TUIVoiceMessageCell *)cell

– showImageMessage:

- (void)showImageMessage:(TUIImageMessageCell *)cell

– showVideoMessage:

- (void)showVideoMessage:(TUIVideoMessageCell *)cell

– showFileMessage:

- (void)showFileMessage:(TUIFileMessageCell *)cell

Extension Methods

  conv

@property (nonatomic, strong) TIMConversation *conv

  uiMsgs

@property (nonatomic, strong) NSMutableArray *uiMsgs

  heightCache

@property (nonatomic, strong) NSMutableArray *heightCache

  msgForDate

@property (nonatomic, strong) TIMMessage *msgForDate

  msgForGet

@property (nonatomic, strong) TIMMessage *msgForGet

  menuUIMsg

@property (nonatomic, strong) TUIMessageCellData *menuUIMsg

  reSendUIMsg

@property (nonatomic, strong) TUIMessageCellData *reSendUIMsg

  indicatorView

@property (nonatomic, strong) UIActivityIndicatorView *indicatorView

  isScrollBottom

@property (nonatomic, assign) BOOL isScrollBottom

  isLoadingMsg

@property (nonatomic, assign) BOOL isLoadingMsg

  noMoreMsg

@property (nonatomic, assign) BOOL noMoreMsg

  firstLoad

@property (nonatomic, assign) BOOL firstLoad

  conversationDataProviderService

@property id<TUIConversationDataProviderServiceProtocol> conversationDataProviderService