TUIImageMessageCellData Class Reference
Inherits from | TUIMessageCellData : TCommonCellData : NSObject |
---|---|
Declared in | TUIImageMessageCellData.h TUIImageMessageCellData.m |
Overview
【模块名称】TUIImageMessageCellData 【功能说明】用于实现聊天窗口中的图片气泡,包括图片消息发送进度的展示也在其中。 同时,该模块已经支持“缩略图”、“大图”和“原图”三种不同的类型,并已经处理好了在合适的情况下展示相应图片类型的业务逻辑: 1. 缩略图 - 默认在聊天窗口中看到的是缩略图,体积较小省流量 2. 大图 - 如果用户点开之后,看到的是分辨率更好的大图 3. 原图 - 如果发送方选择发送原图,那么接收者会看到“原图”按钮,点击下载到原尺寸的图片 数据源帮助实现了 MVVM 架构,使数据与 UI 进一步解耦,同时使 UI 层更加细化、可定制化。
Other Methods
thumbImage
图像缩略图
@property (nonatomic, strong) UIImage *thumbImage
Declared In
TUIImageMessageCellData.h
originImage
图像原图
@property (nonatomic, strong) UIImage *originImage
Declared In
TUIImageMessageCellData.h
largeImage
图像大图
@property (nonatomic, strong) UIImage *largeImage
Declared In
TUIImageMessageCellData.h
path
图像路径
@property (nonatomic, strong) NSString *path
Discussion
Note: path 由程序默认维护,您可以通过引入 THeader.h 并引用 TUIKit_Image_Path 来直接获取Demo存储路径
Note: 如果您有进一步的个性化需求,也可使用其他路径
Declared In
TUIImageMessageCellData.h
length
图像长度(大小)
@property (nonatomic, assign) NSInteger length
Declared In
TUIImageMessageCellData.h
items
图像项目集
@property (nonatomic, strong) NSMutableArray *items
Discussion
Note: items中通常存放三个imageItem,分别为 thumb(缩略图)、origin(原图)、large(大图),方便根据根据需求灵活获取图像
Declared In
TUIImageMessageCellData.h
thumbProgress
缩略图加载进度
@property (nonatomic, assign) NSUInteger thumbProgress
Declared In
TUIImageMessageCellData.h
originProgress
原图加载进度
@property (nonatomic, assign) NSUInteger originProgress
Declared In
TUIImageMessageCellData.h
largeProgress
大图加载进度
@property (nonatomic, assign) NSUInteger largeProgress
Declared In
TUIImageMessageCellData.h
uploadProgress
上传(发送)进度
@property (nonatomic, assign) NSUInteger uploadProgress
Declared In
TUIImageMessageCellData.h
– downloadImage:
获取图像 本函数整合调用了 IM SDK,通过 SDK 提供的接口在线获取图像。 1、下载前会判断图像是否在本地,若不在本地,则在本地直接获取图像。 2、当图像不在本地时,通过 IM SDK 中 TIMImage 提供的 getImage 接口在线获取。 3-1、下载进度百分比则通过接口回调的 progress(代码块)参数进行更新。 3-2、代码块具有 curSize 和 totalSize 两个参数,由回调函数维护 curSize,然后通过 curSize * 100 / totalSize 计算出当前进度百分比。 4-1、图像消息中存放的格式为 TIMElem,图片列表需通过 TIMElem.imageList 获取,在 imalgelist 中,包含了原图、大图与缩略图,可通过 imageType 进一步获取。 4-2、通过 SDK 接口获取的图像为二进制文件,需先进行解码,转换为 CGIamge 进行解码操作后包装为 UIImage 才可使用。 5、下载成功后,会生成图像 path 并存储下来。
- (void)downloadImage:(TUIImageType)type
Declared In
TUIImageMessageCellData.h
– decodeImage:
解码图像,并将图像赋值到对应类型的变量(缩略图、大图或者原图)中。
- (void)decodeImage:(TUIImageType)type
Parameters
type |
图像类型 |
---|
Declared In
TUIImageMessageCellData.h
– getImagePath:isExist:
获取图像路径 同时传入 isExist 指针,能够同时改变 isExist 标识。成功获取图像 path 后,isExist 赋值为 YES,否则赋值为 NO。
- (NSString *)getImagePath:(TUIImageType)type isExist:(BOOL *)isExist
Parameters
type |
图像类型 |
---|---|
isExist |
是否在本地存在 |
Return Value
返回路径的字符串形式。
Declared In
TUIImageMessageCellData.h