temp save: 基本完整显示聊天内容
This commit is contained in:
@@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
///cell的高度
|
///cell的高度
|
||||||
@property (nonatomic,assign) CGFloat rowHeight;
|
@property (nonatomic,assign) CGFloat rowHeight;
|
||||||
@property (nonatomic,assign) CGFloat textWidth;
|
@property (nonatomic,assign) CGFloat textWidth;
|
||||||
|
@property(nonatomic, strong) YYTextLayout *textLayout;
|
||||||
@property(nonatomic, strong) NSMutableArray *extraSizeArray;
|
@property(nonatomic, strong) NSMutableArray *extraSizeArray;
|
||||||
///文本内容的
|
///文本内容的
|
||||||
@property (nonatomic,assign) CGFloat contentLeftMargin;
|
@property (nonatomic,assign) CGFloat contentLeftMargin;
|
||||||
@@ -43,6 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (nonatomic, copy) NSString *boomImageUrl;
|
@property (nonatomic, copy) NSString *boomImageUrl;
|
||||||
|
|
||||||
|
@property(nonatomic, copy) NSString *cellKey;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -28,8 +28,30 @@
|
|||||||
- (void)setContent:(NSAttributedString *)content {
|
- (void)setContent:(NSAttributedString *)content {
|
||||||
_content = content;
|
_content = content;
|
||||||
|
|
||||||
self.rowHeight = [self heightForAttributedText:content
|
CGSize size = [content boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||||
maxWidth:kRoomMessageMaxWidth];
|
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||||
|
context:nil].size;
|
||||||
|
|
||||||
|
YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(size.width, CGFLOAT_MAX)];
|
||||||
|
container.maximumNumberOfRows = 0;
|
||||||
|
container.truncationType = YYTextTruncationTypeEnd;
|
||||||
|
self.textLayout = [YYTextLayout layoutWithContainer:container text:content];
|
||||||
|
|
||||||
|
CGSize textSize = self.textLayout.textBoundingRect.size;
|
||||||
|
// CGFloat anotherHeight = [self heightForAttributedStringUsingTextKit:content maxWidth:kRoomMessageMaxWidth];
|
||||||
|
self.rowHeight = ceil(textSize.height) + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin + 20;
|
||||||
|
if (![NSString isEmpty:self.bubbleImageUrl]) {
|
||||||
|
self.rowHeight += 30;
|
||||||
|
} else {
|
||||||
|
self.rowHeight += 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([self.cellKey isEqualToString:@"ChatMessage"]) {
|
||||||
|
NSLog(@" ----- 11 ----- %@ : %@", [NSValue valueWithCGSize:textSize], [NSValue valueWithCGSize:[self heightForAttributedStringUsingTextKit:content maxWidth:kRoomMessageMaxWidth]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// self.rowHeight = [self heightForAttributedText:content
|
||||||
|
// maxWidth:kRoomMessageMaxWidth];
|
||||||
|
|
||||||
// CGFloat width = isMSRTL() ? 10 : 0;
|
// CGFloat width = isMSRTL() ? 10 : 0;
|
||||||
////// width = self.vipIcon.length > 0 ? width + 15 : width;
|
////// width = self.vipIcon.length > 0 ? width + 15 : width;
|
||||||
@@ -41,7 +63,7 @@
|
|||||||
// self.rowHeight = rowHeight + width ;
|
// self.rowHeight = rowHeight + width ;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)heightForAttributedStringUsingTextKit:(NSAttributedString *)attributedString
|
- (CGSize)heightForAttributedStringUsingTextKit:(NSAttributedString *)attributedString
|
||||||
maxWidth:(CGFloat)maxWidth {
|
maxWidth:(CGFloat)maxWidth {
|
||||||
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
|
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
|
||||||
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX)];
|
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX)];
|
||||||
@@ -52,7 +74,7 @@
|
|||||||
|
|
||||||
// 让布局管理器计算文本高度
|
// 让布局管理器计算文本高度
|
||||||
[layoutManager glyphRangeForTextContainer:textContainer];
|
[layoutManager glyphRangeForTextContainer:textContainer];
|
||||||
return ceil([layoutManager usedRectForTextContainer:textContainer].size.height); // 向上取整
|
return [layoutManager usedRectForTextContainer:textContainer].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)heightForAttributedText:(NSAttributedString *)attributedText maxWidth:(CGFloat)maxWidth {
|
- (CGFloat)heightForAttributedText:(NSAttributedString *)attributedText maxWidth:(CGFloat)maxWidth {
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
#ifndef XPRoomMessageConstant_h
|
#ifndef XPRoomMessageConstant_h
|
||||||
#define XPRoomMessageConstant_h
|
#define XPRoomMessageConstant_h
|
||||||
|
|
||||||
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90)
|
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90 - 8)
|
||||||
|
|
||||||
///公屏文本字体的大小
|
///公屏文本字体的大小
|
||||||
static CGFloat kRoomMessageDefalutFont = 15;
|
static CGFloat kRoomMessageDefalutFont = 15;
|
||||||
|
@@ -59,29 +59,6 @@
|
|||||||
|
|
||||||
@implementation XPRoomMessageParser
|
@implementation XPRoomMessageParser
|
||||||
|
|
||||||
- (XPMessageInfoModel*)parseMessageAttributeForChatHall:(NIMMessage *)message{
|
|
||||||
NIMMessageType messageType = message.messageType;
|
|
||||||
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
|
|
||||||
messageInfo.isChatHall = YES;
|
|
||||||
switch (messageType) {
|
|
||||||
case NIMMessageTypeText:
|
|
||||||
{
|
|
||||||
XPMessageInfoModel *model = [self makeChatAttribute:message messageInfo:messageInfo];
|
|
||||||
return model != nil ? model : [XPMessageInfoModel new];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case NIMMessageTypeCustom:
|
|
||||||
{
|
|
||||||
XPMessageInfoModel *model = [self makeCustomAttribute:message messageInfo:messageInfo];
|
|
||||||
return model != nil ? model : [XPMessageInfoModel new];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return [XPMessageInfoModel new];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (XPMessageInfoModel*)parseBroadcastMessageAttribute:(NIMBroadcastMessage *)message {
|
- (XPMessageInfoModel*)parseBroadcastMessageAttribute:(NIMBroadcastMessage *)message {
|
||||||
if (message.content) {
|
if (message.content) {
|
||||||
NSDictionary *msgDictionary = [message.content toJSONObject];
|
NSDictionary *msgDictionary = [message.content toJSONObject];
|
||||||
@@ -278,72 +255,56 @@
|
|||||||
if ([self isCurrentRoomSuperAdmin:message.from]) {
|
if ([self isCurrentRoomSuperAdmin:message.from]) {
|
||||||
[attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]];
|
[attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![NSString isEmpty:model.experUrl]) {
|
if (![NSString isEmpty:model.experUrl]) {
|
||||||
|
messageInfo.experUrl = model.experUrl;
|
||||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]];
|
[attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]];
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![NSString isEmpty:model.charmUrl]) {//等级
|
if (![NSString isEmpty:model.charmUrl]) {//等级
|
||||||
|
messageInfo.charmUrl = model.charmUrl;
|
||||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.charmUrl]];
|
[attribute appendAttributedString:[self createUrlImageAttribute:model.charmUrl]];
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![NSString isEmpty:model.vipIcon]) {
|
if (![NSString isEmpty:model.vipIcon]) {
|
||||||
|
messageInfo.vipIcon = model.vipIcon;
|
||||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
|
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||||
}
|
}
|
||||||
if(model.isCustomWord == YES){
|
if (model.inRoomNameplatePic.length > 0) {
|
||||||
if (model.inRoomNameplatePic.length > 0){
|
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic
|
||||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
size:CGSizeMake(60, kFontRegular(kRoomMessageDefalutFont).lineHeight)]];
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (model.inRoomNameplatePic.length > 0) { //铭牌有图片加文字
|
|
||||||
[attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
|
||||||
}
|
|
||||||
// if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字
|
|
||||||
// [attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
|
||||||
// [attribute appendAttributedString:[self createSapceAttribute:2]];
|
|
||||||
// } else if (model.inRoomNameplatePic.length > 0) {//铭牌只有图片
|
|
||||||
// [attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
|
||||||
// [attribute appendAttributedString:[self createSapceAttribute:2]];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
[attribute appendAttributedString:[self createTextAttribute:nick color:[UIColor colorWithWhite:1 alpha:0.7] font:kRoomMessageDefalutFont]];
|
||||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||||
|
|
||||||
id nickNameNifo = message.remoteExt[@"atNames"];
|
id nickNameNifo = message.remoteExt[@"atNames"];
|
||||||
NSMutableAttributedString *msgStr;
|
|
||||||
if (message.text) {
|
|
||||||
if(messageInfo.isChatHall == YES){
|
|
||||||
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
|
|
||||||
msgStr = [faceManager attributedStringByText:message.text font:[UIFont systemFontOfSize:kRoomMessageDefalutFont]];
|
|
||||||
[msgStr addAttributes:@{NSForegroundColorAttributeName: [DJDKMIMOMColor messageTextColor]} range:[msgStr.string rangeOfString:msgStr.string]];
|
|
||||||
|
|
||||||
}else{
|
if (message.text) {
|
||||||
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
NSMutableAttributedString *msgStr;
|
||||||
[msgStr addAttribute:NSForegroundColorAttributeName
|
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
||||||
value:[DJDKMIMOMColor messageTextColor]
|
[msgStr addAttribute:NSForegroundColorAttributeName
|
||||||
range:NSMakeRange(0, msgStr.length)];
|
value:[DJDKMIMOMColor messageTextColor]
|
||||||
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
|
range:NSMakeRange(0, msgStr.length)];
|
||||||
for (NSString *nick in nickNameNifo) {
|
[msgStr addAttribute:NSFontAttributeName
|
||||||
NSRange range = [message.text rangeOfString:nick];
|
value:kFontRegular(kRoomMessageDefalutFont)
|
||||||
if (range.length) {
|
range:NSMakeRange(0, msgStr.length)];
|
||||||
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
|
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
|
||||||
}
|
for (NSString *nick in nickNameNifo) {
|
||||||
|
NSRange range = [message.text rangeOfString:nick];
|
||||||
|
if (range.length) {
|
||||||
|
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[attribute appendAttributedString:msgStr];
|
[attribute appendAttributedString:msgStr];
|
||||||
}
|
}
|
||||||
if(messageInfo.isChatHall == NO){
|
|
||||||
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
||||||
|
|
||||||
|
messageInfo.cellKey = @"ChatMessage";
|
||||||
messageInfo.content = attribute;
|
messageInfo.content = attribute;
|
||||||
messageInfo.vipIcon = model.vipIcon;
|
|
||||||
return messageInfo;
|
return messageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +541,6 @@
|
|||||||
if ([attribute.string containsString:[NSString stringWithFormat:@"{%@}",model.key]]){
|
if ([attribute.string containsString:[NSString stringWithFormat:@"{%@}",model.key]]){
|
||||||
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attImage];
|
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attImage];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
messageInfo.content = attribute;
|
messageInfo.content = attribute;
|
||||||
@@ -1392,15 +1352,42 @@
|
|||||||
|
|
||||||
#pragma mark - private base methods
|
#pragma mark - private base methods
|
||||||
///铭牌
|
///铭牌
|
||||||
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
|
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName
|
||||||
|
image:(NSString *)imageName
|
||||||
|
textFont:(UIFont *)textFont {
|
||||||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||||||
///先这样吧
|
///先这样吧
|
||||||
|
CGSize defaultSize = CGSizeMake(60, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||||
config.autoLoad = YES;
|
config.autoLoad = YES;
|
||||||
NetImageView *imageView = [[NetImageView alloc] initWithUrl:imageName config:config];
|
NetImageView *imageView = [[NetImageView alloc] initWithUrl:imageName config:config];
|
||||||
UIImage* image = imageView.image;
|
imageView.bounds = CGRectMake(0, 0, defaultSize.width, defaultSize.height);
|
||||||
|
|
||||||
|
// 异步加载图片
|
||||||
|
@kWeakify(self);
|
||||||
|
[imageView loadImageWithUrl:imageName completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||||
|
@kStrongify(self);
|
||||||
|
if (image) {
|
||||||
|
CGFloat scale = image.size.width / image.size.height;
|
||||||
|
CGSize newSize = scale > 0 ? CGSizeMake(60 * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight) : defaultSize;
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
imageView.bounds = CGRectMake(0, 0, newSize.width, newSize.height);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
// [imageView loadImageWithUrl:imageName completion:^(UIImage * _Nullable loadedImage) {
|
||||||
|
// @kStrongify(self);
|
||||||
|
// if (loadedImage) {
|
||||||
|
// CGFloat scale = loadedImage.size.width / loadedImage.size.height;
|
||||||
|
// CGSize newSize = scale > 0 ? CGSizeMake(18 * scale, 18) : defaultSize;
|
||||||
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
// imageView.bounds = CGRectMake(0, 0, newSize.width, newSize.height);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }];
|
||||||
|
|
||||||
|
// UIImage* image = imageView.image;
|
||||||
// if (image) {
|
// if (image) {
|
||||||
// CGFloat scale = image.size.width / image.size.height;
|
// CGFloat scale = image.size.width / image.size.height;
|
||||||
// imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
|
|
||||||
// } else {
|
// } else {
|
||||||
// NSURL *imgUrl = [NSURL URLWithString:imageName];
|
// NSURL *imgUrl = [NSURL URLWithString:imageName];
|
||||||
// UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
// UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||||||
@@ -1412,9 +1399,10 @@
|
|||||||
// imageView.bounds = CGRectMake(0, 0, 18* scale, 18);
|
// imageView.bounds = CGRectMake(0, 0, 18* scale, 18);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
imageView.bounds = CGRectMake(0, 0, 60, 18);
|
// imageView.bounds = CGRectMake(0, 0, 60, 18);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
// 铭牌文字
|
// 铭牌文字
|
||||||
if (![NSString isEmpty:tagName]) {
|
if (![NSString isEmpty:tagName]) {
|
||||||
@@ -1432,7 +1420,11 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
|
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView
|
||||||
|
contentMode:UIViewContentModeScaleAspectFit
|
||||||
|
attachmentSize:imageView.bounds.size
|
||||||
|
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||||
|
alignment:YYTextVerticalAlignmentCenter];
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1453,7 +1445,7 @@
|
|||||||
}
|
}
|
||||||
imageView.layer.masksToBounds = YES;
|
imageView.layer.masksToBounds = YES;
|
||||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||||
return attrString;
|
return attrString;
|
||||||
}
|
}
|
||||||
/// 生成一个图片的富文本
|
/// 生成一个图片的富文本
|
||||||
@@ -1467,7 +1459,7 @@
|
|||||||
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||||||
imageView.layer.masksToBounds = YES;
|
imageView.layer.masksToBounds = YES;
|
||||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||||
return attrString;
|
return attrString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1481,7 +1473,7 @@
|
|||||||
imaveView.image = [UIImage imageNamed:imageName];
|
imaveView.image = [UIImage imageNamed:imageName];
|
||||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||||
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
|
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
|
||||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||||
return attrString;
|
return attrString;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,11 @@
|
|||||||
size = CGSizeMake(16, 16);
|
size = CGSizeMake(16, 16);
|
||||||
imageView.bounds = CGRectMake(0, 0, 16, 16);
|
imageView.bounds = CGRectMake(0, 0, 16, 16);
|
||||||
}
|
}
|
||||||
NSMutableAttributedString * replaceAttr = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:size alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
NSMutableAttributedString * replaceAttr = [NSMutableAttributedString yy_attachmentStringWithContent:imageView
|
||||||
|
contentMode:UIViewContentModeScaleAspectFit
|
||||||
|
attachmentSize:size
|
||||||
|
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||||
|
alignment:YYTextVerticalAlignmentCenter];
|
||||||
[attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
[attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
@@ -41,8 +41,11 @@
|
|||||||
|
|
||||||
#pragma mark - Private Method
|
#pragma mark - Private Method
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
|
self.clipsToBounds = NO;
|
||||||
|
self.contentView.clipsToBounds = NO;
|
||||||
|
|
||||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||||
self.backgroundColor = [UIColor clearColor];
|
self.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:0.4];//[UIColor clearColor];
|
||||||
[self.contentView addSubview:self.bubbleImageView];
|
[self.contentView addSubview:self.bubbleImageView];
|
||||||
[self.contentView addSubview:self.contentLabel];
|
[self.contentView addSubview:self.contentLabel];
|
||||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap)];
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap)];
|
||||||
@@ -56,19 +59,16 @@
|
|||||||
- (void)initSubViewConstraints {
|
- (void)initSubViewConstraints {
|
||||||
|
|
||||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.leading.mas_equalTo(self.contentLabel).offset(-12);
|
make.leading.mas_equalTo(self.contentLabel).offset(-20);
|
||||||
make.top.mas_equalTo(self.contentLabel).offset(-10);
|
make.top.mas_equalTo(self.contentLabel).offset(-10);
|
||||||
make.bottom.mas_equalTo(self.contentLabel).offset(10);
|
make.bottom.mas_equalTo(self.contentLabel);//.offset(10);
|
||||||
make.trailing.mas_equalTo(self.contentLabel).offset(10);
|
make.trailing.mas_equalTo(self.contentLabel).offset(20);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.leading.mas_equalTo(12);
|
make.leading.mas_equalTo(12);
|
||||||
make.bottom.mas_equalTo(-20);
|
make.bottom.mas_equalTo(-20);
|
||||||
make.top.mas_equalTo(10);
|
make.top.mas_equalTo(10);
|
||||||
if (isMSRTL()) {
|
|
||||||
make.width.mas_equalTo(20);
|
|
||||||
}
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,50 +129,79 @@
|
|||||||
}
|
}
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
- (void)setMessageInfo:(XPMessageInfoModel *)messageInfo {
|
- (void)setMessageInfo:(XPMessageInfoModel *)messageInfo {
|
||||||
|
if ([messageInfo.content isEqualToAttributedString:_messageInfo.content]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_messageInfo = messageInfo;
|
_messageInfo = messageInfo;
|
||||||
if (_messageInfo) {
|
if (messageInfo) {
|
||||||
self.contentLabel.attributedText = _messageInfo.content;
|
|
||||||
|
|
||||||
if (_messageInfo.bubbleImageUrl.length) {
|
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||||
|
// make.leading.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentLeftMargin);
|
||||||
|
// make.top.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentTopMargin);
|
||||||
|
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentBottomMargin);
|
||||||
|
// }];
|
||||||
|
|
||||||
|
self.contentLabel.attributedText = messageInfo.content;
|
||||||
|
// self.contentLabel.textLayout = messageInfo.textLayout;
|
||||||
|
|
||||||
|
if (messageInfo.bubbleImageUrl.length) {
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
[self.bubbleImageView loadImageWithUrl:_messageInfo.bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
[self.bubbleImageView loadImageWithUrl:messageInfo.bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||||
@kStrongify(self);
|
@kStrongify(self);
|
||||||
UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp];
|
UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp];
|
||||||
UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
|
UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
|
||||||
self.bubbleImageView.image = [self resizableImage:cutImage];
|
self.bubbleImageView.image = [self resizableImage:cutImage];
|
||||||
}];
|
}];
|
||||||
}
|
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.leading.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentLeftMargin + 12);
|
||||||
if (self.isLeftBigImage) {
|
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin+20);
|
||||||
self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
|
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin-10);
|
||||||
[self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
make.top.mas_equalTo(-10);
|
||||||
make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
make.bottom.mas_equalTo(0);
|
||||||
make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
|
if (isMSRTL()) { // MARK: 可能会有性能问题,但源代码已经使用了更新 layout 的方案,推测是头像框和气泡会导致卡顿
|
||||||
// make.centerY.mas_equalTo(self.contentView);
|
make.width.mas_greaterThanOrEqualTo([self RTLLabelWidth]);
|
||||||
make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
}
|
||||||
make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
|
||||||
// if (isMSRTL()) {
|
|
||||||
// make.width.mas_equalTo([self RTLLabelWidth] - 65);
|
|
||||||
// }
|
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
[self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||||
make.leading.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentLeftMargin);
|
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
make.edges.mas_equalTo(self.contentView).inset(10);
|
||||||
make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
// make.leading.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentLeftMargin + 12);
|
||||||
if (isMSRTL()) { // MARK: 可能会有性能问题,但源代码已经使用了更新 layout 的方案,推测是头像框和气泡会导致卡顿
|
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin+10);
|
||||||
make.width.mas_equalTo([self RTLLabelWidth]);
|
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin-20);
|
||||||
}
|
// if (isMSRTL()) { // MARK: 可能会有性能问题,但源代码已经使用了更新 layout 的方案,推测是头像框和气泡会导致卡顿
|
||||||
|
// make.width.mas_greaterThanOrEqualTo([self RTLLabelWidth]);
|
||||||
|
// }
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
_bubbleImageView.hidden = _messageInfo.isHiddenBubble;
|
// if (self.isLeftBigImage) {
|
||||||
// [self layoutIfNeeded];
|
// self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
|
||||||
|
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||||
|
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||||
|
// make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
|
||||||
|
//// make.centerY.mas_equalTo(self.contentView);
|
||||||
|
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||||
|
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||||
|
//// if (isMSRTL()) {
|
||||||
|
//// make.width.mas_equalTo([self RTLLabelWidth] - 65);
|
||||||
|
//// }
|
||||||
|
// }];
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _bubbleImageView.hidden = _messageInfo.isHiddenBubble;
|
||||||
|
[self layoutIfNeeded];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)RTLLabelWidth {
|
- (CGFloat)RTLLabelWidth {
|
||||||
return MIN(self.contentLabel.textWidth + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8, self.contentLabel.maxWidth);
|
CGSize size = [self.contentLabel.attributedText boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||||
|
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||||
|
context:nil].size;
|
||||||
|
NSLog(@" ----- 11 ----- %@", [NSValue valueWithCGSize:size]);
|
||||||
|
return MIN(ceil(size.width) + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8, self.contentLabel.maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImage *)scaleToSize:(UIImage *)img {
|
- (UIImage *)scaleToSize:(UIImage *)img {
|
||||||
@@ -207,6 +236,7 @@
|
|||||||
- (NetImageView *)bubbleImageView {
|
- (NetImageView *)bubbleImageView {
|
||||||
if (!_bubbleImageView) {
|
if (!_bubbleImageView) {
|
||||||
_bubbleImageView = [[NetImageView alloc] init];
|
_bubbleImageView = [[NetImageView alloc] init];
|
||||||
|
_bubbleImageView.clipsToBounds = NO;
|
||||||
_bubbleImageView.userInteractionEnabled = YES;
|
_bubbleImageView.userInteractionEnabled = YES;
|
||||||
_bubbleImageView.layer.masksToBounds = YES;
|
_bubbleImageView.layer.masksToBounds = YES;
|
||||||
_bubbleImageView.layer.cornerRadius = 7;
|
_bubbleImageView.layer.cornerRadius = 7;
|
||||||
|
@@ -105,7 +105,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
|
|
||||||
- (void)changeType:(NSInteger)type {
|
- (void)changeType:(NSInteger)type {
|
||||||
self.displayType = type;
|
self.displayType = type;
|
||||||
[self updateAllDataSource];
|
// [self updateAllDataSource];
|
||||||
[self.messageTableView reloadData];
|
[self.messageTableView reloadData];
|
||||||
|
|
||||||
if (self.displayType == 1) {
|
if (self.displayType == 1) {
|
||||||
@@ -119,11 +119,15 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateAllDataSource {
|
/// 更新其他 tag 的数据源,若传入空数组,则初始化并从 datasource 中获取数据
|
||||||
self.datasource_chat = @[].mutableCopy;
|
- (void)updateAllDataSource:(NSArray *)datas {
|
||||||
self.datasource_gift = @[].mutableCopy;
|
if (!datas || datas.count == 0) {
|
||||||
|
self.datasource_chat = @[].mutableCopy;
|
||||||
|
self.datasource_gift = @[].mutableCopy;
|
||||||
|
datas = self.datasource;
|
||||||
|
}
|
||||||
|
|
||||||
for (XPMessageInfoModel *model in self.datasource) {
|
for (XPMessageInfoModel *model in datas) {
|
||||||
switch (model.first) {
|
switch (model.first) {
|
||||||
case NIMMessageTypeText:
|
case NIMMessageTypeText:
|
||||||
[self.datasource_chat addObject:model];
|
[self.datasource_chat addObject:model];
|
||||||
@@ -198,7 +202,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||||
[self updateAllDataSource];
|
[self updateAllDataSource:nil];
|
||||||
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
||||||
for (int i = 0; i<self.locationArray.count; i++) {///移除掉前面消息的数据后,前面如果有at我的消息,也一并移除掉
|
for (int i = 0; i<self.locationArray.count; i++) {///移除掉前面消息的数据后,前面如果有at我的消息,也一并移除掉
|
||||||
NSNumber *number = self.locationArray[i];
|
NSNumber *number = self.locationArray[i];
|
||||||
@@ -216,7 +220,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 执行插入
|
// 执行插入
|
||||||
NSMutableArray *indexPaths = [NSMutableArray array];
|
NSMutableArray *indexPaths = @[].mutableCopy;
|
||||||
|
NSMutableArray *tempNewDatas = @[].mutableCopy;
|
||||||
for (id item in self.incomingMessages) {
|
for (id item in self.incomingMessages) {
|
||||||
XPMessageInfoModel *model = nil;
|
XPMessageInfoModel *model = nil;
|
||||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||||
@@ -227,6 +232,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
if (!model) {
|
if (!model) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
[tempNewDatas addObject:model];
|
||||||
[self.datasource addObject:model];
|
[self.datasource addObject:model];
|
||||||
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
||||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||||
@@ -240,7 +246,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self updateAllDataSource];
|
[self updateAllDataSource:tempNewDatas];
|
||||||
[self.incomingMessages removeAllObjects];
|
[self.incomingMessages removeAllObjects];
|
||||||
[self.messageTableView reloadData];
|
[self.messageTableView reloadData];
|
||||||
|
|
||||||
@@ -253,6 +259,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
self.atTipBtn.hidden = YES;
|
self.atTipBtn.hidden = YES;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = [self.locationArray[0] intValue];
|
int index = [self.locationArray[0] intValue];
|
||||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||||
if (rows > indexPath.row) {
|
if (rows > indexPath.row) {
|
||||||
@@ -306,6 +313,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
|
|
||||||
#pragma mark - Private Method
|
#pragma mark - Private Method
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
|
self.clipsToBounds = YES;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil];
|
||||||
[self addSubview:self.messageTableView];
|
[self addSubview:self.messageTableView];
|
||||||
[self addSubview:self.messageTipsBtn];
|
[self addSubview:self.messageTipsBtn];
|
||||||
@@ -379,7 +387,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (self.isPending) {
|
if (self.isPending) {
|
||||||
self.messageTipsBtn.hidden = NO;
|
self.messageTipsBtn.hidden = NO;
|
||||||
[self findAtMeNumber];
|
[self findAtMeNumber];
|
||||||
@@ -402,26 +409,26 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行插入
|
|
||||||
// for (NIMMessage *item in self.incomingMessages) {
|
NSMutableArray *tempArray = @[].mutableCopy;
|
||||||
// XPMessageInfoModel *model = [self.messageParser parseMessageAttribute:item];
|
@kWeakify(self);
|
||||||
// [self.datasource addObject:model];
|
|
||||||
// }
|
|
||||||
[self.incomingMessages enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[self.incomingMessages enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
|
@kStrongify(self);
|
||||||
|
id model = nil;
|
||||||
if ([obj isKindOfClass:[NIMMessage class]]) {
|
if ([obj isKindOfClass:[NIMMessage class]]) {
|
||||||
XPMessageInfoModel *model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||||
[self.datasource addObject:model];
|
|
||||||
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||||
XPMessageInfoModel *model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||||
if (model) {
|
}
|
||||||
[self.datasource addObject:model];
|
if (model) {
|
||||||
}
|
[tempArray addObject:model];
|
||||||
|
[self.datasource addObject:model];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self updateAllDataSource];
|
|
||||||
|
|
||||||
[self.incomingMessages removeAllObjects];
|
[self.incomingMessages removeAllObjects];
|
||||||
|
|
||||||
|
[self updateAllDataSource:tempArray];
|
||||||
[self.messageTableView reloadData];
|
[self.messageTableView reloadData];
|
||||||
|
|
||||||
//执行插入动画并滚动
|
//执行插入动画并滚动
|
||||||
@@ -746,9 +753,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||||
if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
if (attachment.first == CustomMessageType_Update_RoomInfo &&
|
||||||
|
attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
||||||
[self.datasource removeAllObjects];
|
[self.datasource removeAllObjects];
|
||||||
[self updateAllDataSource];
|
[self updateAllDataSource:nil];
|
||||||
[self.incomingMessages removeAllObjects];
|
[self.incomingMessages removeAllObjects];
|
||||||
[self.locationArray removeAllObjects];
|
[self.locationArray removeAllObjects];
|
||||||
self.atCount = 0;
|
self.atCount = 0;
|
||||||
@@ -758,9 +766,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||||
[self addRoomMessage:message];
|
[self addRoomMessage:message];
|
||||||
return;
|
return;
|
||||||
} else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
|
} else if (attachment.first == CustomMessageType_Update_RoomInfo &&
|
||||||
|
attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
|
||||||
[self.datasource removeAllObjects];
|
[self.datasource removeAllObjects];
|
||||||
[self updateAllDataSource];
|
[self updateAllDataSource:nil];
|
||||||
[self.incomingMessages removeAllObjects];
|
[self.incomingMessages removeAllObjects];
|
||||||
[self.locationArray removeAllObjects];
|
[self.locationArray removeAllObjects];
|
||||||
self.atCount = 0;
|
self.atCount = 0;
|
||||||
@@ -770,7 +779,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||||
[self addRoomMessage:message];
|
[self addRoomMessage:message];
|
||||||
return;
|
return;
|
||||||
} else if(attachment.first == CustomMessageType_Candy_Tree && attachment.second == Custom_Message_Sub_Candy_Tree_Me) {
|
} else if(attachment.first == CustomMessageType_Candy_Tree &&
|
||||||
|
attachment.second == Custom_Message_Sub_Candy_Tree_Me) {
|
||||||
CandyTreeGiftInfoModel * model = [CandyTreeGiftInfoModel modelWithDictionary:attachment.data];
|
CandyTreeGiftInfoModel * model = [CandyTreeGiftInfoModel modelWithDictionary:attachment.data];
|
||||||
if (model.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
|
if (model.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
|
||||||
return;
|
return;
|
||||||
@@ -862,6 +872,50 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)handleFetchNewestMessage:(NIMMessage *)message {
|
||||||
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||||
|
NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
||||||
|
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
|
||||||
|
option.limit = [ClientConfig shareConfig].configInfo.roomMessageCount;
|
||||||
|
option.order = NIMMessageSearchOrderDesc;
|
||||||
|
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
||||||
|
@kWeakify(self);
|
||||||
|
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId
|
||||||
|
option:option
|
||||||
|
result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||||
|
@kStrongify(self);
|
||||||
|
if(error != nil){
|
||||||
|
self.isLoadHistoryMessage = NO;
|
||||||
|
}
|
||||||
|
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||||
|
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||||
|
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||||
|
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||||
|
}
|
||||||
|
// 执行插入
|
||||||
|
for (NIMMessage *item in messages.reverseObjectEnumerator) {
|
||||||
|
[self dealWithHistoryDataWithMessage:item];
|
||||||
|
}
|
||||||
|
self.isLoadHistoryMessage = NO;
|
||||||
|
BOOL hideEnter = [self handleHideEnter:message];
|
||||||
|
if (!hideEnter) {
|
||||||
|
///插入进房消息及房间公告提示
|
||||||
|
[self addRoomMessage:message];
|
||||||
|
}
|
||||||
|
if (!roomInfo.hasAnimationEffect) {
|
||||||
|
[self roomInfoNoGiftAnimationMessage:message];
|
||||||
|
}
|
||||||
|
[self createUserEnterRoomAddRoomTopicMessage];
|
||||||
|
|
||||||
|
[self updateAllDataSource:nil];
|
||||||
|
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[self.messageTableView reloadData];
|
||||||
|
[self scrollToBottom:YES];
|
||||||
|
});
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)handleFetchHistoryMessage:(NIMMessage *)message {
|
- (void)handleFetchHistoryMessage:(NIMMessage *)message {
|
||||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||||
NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
||||||
@@ -870,79 +924,45 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
option.startTime = self.hostDelegate.getRoomInfo.clearScreenTime / 1000.0;
|
option.startTime = self.hostDelegate.getRoomInfo.clearScreenTime / 1000.0;
|
||||||
option.order = NIMMessageSearchOrderAsc;
|
option.order = NIMMessageSearchOrderAsc;
|
||||||
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
||||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId
|
||||||
|
option:option
|
||||||
|
result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||||
if(error != nil){
|
if(error != nil){
|
||||||
self.isLoadHistoryMessage = NO;
|
self.isLoadHistoryMessage = NO;
|
||||||
}
|
}
|
||||||
if (messages.count) {
|
if (messages.count) {
|
||||||
//如果拉取的数量等于请求的数量,说明这个时间点以后的消息数量大于等于需要拉取的数量,直接拉取最新的50条
|
//如果拉取的数量等于请求的数量,说明这个时间点以后的消息数量大于等于需要拉取的数量,直接拉取最新的50条
|
||||||
if (messages.count == [ClientConfig shareConfig].configInfo.roomMessageCount) {
|
if (messages.count == [ClientConfig shareConfig].configInfo.roomMessageCount) {
|
||||||
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
|
[self handleFetchNewestMessage:message];
|
||||||
option.limit = [ClientConfig shareConfig].configInfo.roomMessageCount;
|
} else {
|
||||||
option.order = NIMMessageSearchOrderDesc;
|
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||||
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||||
@kWeakify(self);
|
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||||
@kStrongify(self);
|
}
|
||||||
if(error != nil){
|
// 执行插入
|
||||||
self.isLoadHistoryMessage = NO;
|
for (NIMMessage *item in messages) {
|
||||||
}
|
[self dealWithHistoryDataWithMessage:item];
|
||||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
}
|
||||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
|
||||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
|
||||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
|
||||||
}
|
|
||||||
// 执行插入
|
|
||||||
for (NIMMessage *item in messages.reverseObjectEnumerator) {
|
|
||||||
[self dealWithHistoryDataWithMessage:item];
|
|
||||||
}
|
|
||||||
self.isLoadHistoryMessage = NO;
|
|
||||||
BOOL hideEnter = [self handleHideEnter:message];
|
|
||||||
if (!hideEnter) {
|
|
||||||
///插入进房消息及房间公告提示
|
|
||||||
[self addRoomMessage:message];
|
|
||||||
}
|
|
||||||
if (!roomInfo.hasAnimationEffect) {
|
|
||||||
[self roomInfoNoGiftAnimationMessage:message];
|
|
||||||
}
|
|
||||||
[self createUserEnterRoomAddRoomTopicMessage];
|
|
||||||
|
|
||||||
[self updateAllDataSource];
|
self.isLoadHistoryMessage = NO;
|
||||||
|
BOOL hideEnter = [self handleHideEnter:message];
|
||||||
|
if (!hideEnter) {
|
||||||
|
///插入进房消息及房间公告提示
|
||||||
|
[self addRoomMessage:message];
|
||||||
|
}
|
||||||
|
if (!roomInfo.hasAnimationEffect) {
|
||||||
|
[self roomInfoNoGiftAnimationMessage:message];
|
||||||
|
}
|
||||||
|
[self createUserEnterRoomAddRoomTopicMessage];
|
||||||
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
[self updateAllDataSource:nil];
|
||||||
[self.messageTableView reloadData];
|
|
||||||
[self scrollToBottom:YES];
|
|
||||||
});
|
|
||||||
}];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
|
||||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
|
||||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
|
||||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
|
||||||
}
|
|
||||||
// 执行插入
|
|
||||||
for (NIMMessage *item in messages) {
|
|
||||||
[self dealWithHistoryDataWithMessage:item];
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isLoadHistoryMessage = NO;
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
BOOL hideEnter = [self handleHideEnter:message];
|
[self.messageTableView reloadData];
|
||||||
if (!hideEnter) {
|
[self scrollToBottom:YES];
|
||||||
///插入进房消息及房间公告提示
|
});
|
||||||
[self addRoomMessage:message];
|
|
||||||
}
|
}
|
||||||
if (!roomInfo.hasAnimationEffect) {
|
|
||||||
[self roomInfoNoGiftAnimationMessage:message];
|
|
||||||
}
|
|
||||||
[self createUserEnterRoomAddRoomTopicMessage];
|
|
||||||
|
|
||||||
[self updateAllDataSource];
|
|
||||||
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
||||||
[self.messageTableView reloadData];
|
|
||||||
[self scrollToBottom:YES];
|
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{///回到主线程
|
dispatch_async(dispatch_get_main_queue(), ^{///回到主线程
|
||||||
self.isLoadHistoryMessage = NO;
|
self.isLoadHistoryMessage = NO;
|
||||||
@@ -1013,20 +1033,22 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
self.isLoadHistoryMessage = NO;
|
self.isLoadHistoryMessage = NO;
|
||||||
///最小化进房 不需要请求任何接口 但是如果不加延迟的话 无法滚动到底部 原因还不知道
|
///最小化进房 不需要请求任何接口 但是如果不加延迟的话 无法滚动到底部 原因还不知道
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
NSMutableArray *tempArray = @[].mutableCopy;
|
||||||
NSArray * temArray = [XPRoomMiniManager shareManager].getLocalCurrentRoomMessage;
|
NSArray * temArray = [XPRoomMiniManager shareManager].getLocalCurrentRoomMessage;
|
||||||
[temArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[temArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
|
id model = nil;
|
||||||
if ([obj isKindOfClass:[NIMMessage class]]) {
|
if ([obj isKindOfClass:[NIMMessage class]]) {
|
||||||
XPMessageInfoModel *model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||||
[self.datasource addObject:model];
|
|
||||||
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||||
XPMessageInfoModel *model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||||
if (model) {
|
}
|
||||||
[self.datasource addObject:model];
|
if (model) {
|
||||||
}
|
[tempArray addObject:model];
|
||||||
|
[self.datasource addObject:model];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self updateAllDataSource];
|
[self updateAllDataSource:tempArray];
|
||||||
[self.messageTableView reloadData];
|
[self.messageTableView reloadData];
|
||||||
//执行插入动画并滚动
|
//执行插入动画并滚动
|
||||||
[self scrollToBottom:YES];
|
[self scrollToBottom:YES];
|
||||||
@@ -1096,34 +1118,35 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
NSArray *source = @[];
|
// NSArray *source = @[];
|
||||||
switch (self.displayType) {
|
// switch (self.displayType) {
|
||||||
case 1:
|
// case 1:
|
||||||
source = self.datasource;
|
// source = self.datasource;
|
||||||
break;
|
// break;
|
||||||
case 2:
|
// case 2:
|
||||||
source = self.datasource_chat;
|
// source = self.datasource_chat;
|
||||||
break;
|
// break;
|
||||||
case 3:
|
// case 3:
|
||||||
source = self.datasource_gift;
|
// source = self.datasource_gift;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
default:
|
// default:
|
||||||
source = self.datasource;
|
// source = self.datasource;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
// XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||||
|
//
|
||||||
// 如果 model 中有高度数据,使用 model 的高度
|
// // 如果 model 中有高度数据,使用 model 的高度
|
||||||
if (model.rowHeight > 0) {
|
// if (model.rowHeight > 0) {
|
||||||
return model.rowHeight;
|
// return model.rowHeight;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 否则,使用自适应高度
|
// // 否则,使用自适应高度
|
||||||
return UITableViewAutomaticDimension;
|
// return 100;
|
||||||
}
|
//// return UITableViewAutomaticDimension;
|
||||||
|
//}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||||
switch (self.displayType) {
|
switch (self.displayType) {
|
||||||
@@ -1161,7 +1184,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||||
NSString *cellKey = NSStringFromClass([XPRoomMessageTableViewCell class]);
|
NSString *cellKey = [NSString isEmpty:model.cellKey] ? NSStringFromClass([XPRoomMessageTableViewCell class]) : model.cellKey;
|
||||||
if(model.first == CustomMessageType_Room_Album){
|
if(model.first == CustomMessageType_Room_Album){
|
||||||
PIRoomMessagePhotoAlbumCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
PIRoomMessagePhotoAlbumCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
||||||
cell.delegate = self;
|
cell.delegate = self;
|
||||||
@@ -1182,7 +1205,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
|
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
// NSArray *source = @[];
|
// NSArray *source = @[];
|
||||||
// switch (self.displayType) {
|
// switch (self.displayType) {
|
||||||
// case 1:
|
// case 1:
|
||||||
@@ -1203,7 +1226,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
// if (model.rowHeight == 0) {
|
// if (model.rowHeight == 0) {
|
||||||
// model.rowHeight = CGRectGetHeight(cell.frame);
|
// model.rowHeight = CGRectGetHeight(cell.frame);
|
||||||
// }
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - XPRoomMessageTableViewCellDelegate
|
#pragma mark - XPRoomMessageTableViewCellDelegate
|
||||||
@@ -1313,18 +1336,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
|||||||
_messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
_messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||||
_messageTableView.delegate = self;
|
_messageTableView.delegate = self;
|
||||||
_messageTableView.dataSource = self;
|
_messageTableView.dataSource = self;
|
||||||
_messageTableView.rowHeight = UITableViewAutomaticDimension;
|
// _messageTableView.rowHeight = UITableViewAutomaticDimension;
|
||||||
_messageTableView.estimatedRowHeight = 44; // 预估高度
|
// _messageTableView.estimatedRowHeight = 44; // 预估高度
|
||||||
_messageTableView.tableFooterView = [UIView new];
|
_messageTableView.tableFooterView = [UIView new];
|
||||||
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
_messageTableView.backgroundColor = [UIColor clearColor];
|
_messageTableView.backgroundColor = [UIColor clearColor];
|
||||||
_messageTableView.showsVerticalScrollIndicator = NO;
|
_messageTableView.showsVerticalScrollIndicator = NO;
|
||||||
|
_messageTableView.clipsToBounds = NO;
|
||||||
_messageTableView.tag = 666;
|
_messageTableView.tag = 666;
|
||||||
if (@available(iOS 11.0, *)) {
|
if (@available(iOS 11.0, *)) {
|
||||||
_messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
_messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||||
}
|
}
|
||||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:@"XPRoomMessageTableViewCell_Boom"];
|
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:@"XPRoomMessageTableViewCell_Boom"];
|
||||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
||||||
|
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:@"ChatMessage"];
|
||||||
[_messageTableView registerClass:[PIRoomMessagePhotoAlbumCell class] forCellReuseIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
[_messageTableView registerClass:[PIRoomMessagePhotoAlbumCell class] forCellReuseIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,8 @@
|
|||||||
|
|
||||||
///公屏默认背景的颜色
|
///公屏默认背景的颜色
|
||||||
+ (UIColor *)messageBubbleColor {
|
+ (UIColor *)messageBubbleColor {
|
||||||
return UIColorRGBAlpha(0xFFFFFF, 0.15);
|
// return UIColorRGBAlpha(0xFFFFFF, 0.15);
|
||||||
|
return UIColorRGBAlpha(0x000000, 0.35);
|
||||||
}
|
}
|
||||||
///公屏文字的颜色
|
///公屏文字的颜色
|
||||||
+ (UIColor *)messageTextColor {
|
+ (UIColor *)messageTextColor {
|
||||||
|
Reference in New Issue
Block a user