YOUPAILCMultiImageAttachment.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // YOUPAILCMultiImageAttachment.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/22.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCMultiImageAttachment.h"
  9. @implementation YOUPAILCMultiImageAttachment
  10. - (NSString *)encodeAttachment
  11. {
  12. NSDictionary *dict = @{
  13. CMType : @(CustomMultiImage),
  14. CMData : self.imageArray?self.imageArray:@[]
  15. };
  16. NSData *data = [NSJSONSerialization dataWithJSONObject:dict
  17. options:0
  18. error:nil];
  19. NSString *content = nil;
  20. if (data) {
  21. content = [[NSString alloc] initWithData:data
  22. encoding:NSUTF8StringEncoding];
  23. }
  24. return content;
  25. }
  26. - (NSString *)cellContent:(NIMMessage *)message{
  27. return @"YOUPAILCMultiImageContentView";
  28. }
  29. - (CGSize)contentSize:(NIMMessageModel *)model cellWidth:(CGFloat)width{
  30. if (self.imageArray.count>0) {
  31. return CGSizeMake(KScreenWidth-30, (KScreenWidth-30)*9/16+100*(self.imageArray.count-1));
  32. }else{
  33. return CGSizeMake(0, 0);
  34. }
  35. }
  36. - (UIEdgeInsets)contentViewInsets:(NIMMessage *)message
  37. {
  38. return UIEdgeInsetsZero;
  39. // CGFloat bubblePaddingForImage = 3.f;
  40. // CGFloat bubbleArrowWidthForImage = 5.f;
  41. // if (message.isOutgoingMsg) {
  42. // return UIEdgeInsetsMake(bubblePaddingForImage,bubblePaddingForImage,bubblePaddingForImage,bubblePaddingForImage + bubbleArrowWidthForImage);
  43. // }else{
  44. // return UIEdgeInsetsMake(bubblePaddingForImage,bubblePaddingForImage + bubbleArrowWidthForImage, bubblePaddingForImage,bubblePaddingForImage);
  45. // }
  46. }
  47. @end