JXMessageCell.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. //
  2. // JXMessageCell.m
  3. // shiku_im
  4. //
  5. // Created by Apple on 16/10/10.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. static CGFloat kuangkkHHH;
  9. #import "JXMessageCell.h"
  10. #import "emojiViewController.h"
  11. #import "EmojiTextAttachment.h"
  12. //#define TEXT_MAX_HEIGHT 500.0f
  13. @implementation JXMessageCell
  14. - (void)awakeFromNib {
  15. [super awakeFromNib];
  16. // self.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, 55);
  17. kuangkkHHH=0;
  18. }
  19. - (void)dealloc {
  20. [self.readDelTimer invalidate];
  21. self.readDelTimer = nil;
  22. }
  23. -(void)creatUI{
  24. _messageConent=[[JXEmoji alloc] init];
  25. _messageConent.userInteractionEnabled = YES;
  26. _messageConent.lineBreakMode = NSLineBreakByWordWrapping;
  27. _messageConent.numberOfLines = 0;
  28. _messageConent.backgroundColor = [UIColor clearColor];
  29. [self.bubbleBg addSubview:_messageConent];
  30. _timeIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
  31. _timeIndexLabel.layer.cornerRadius = _timeIndexLabel.frame.size.width / 2;
  32. _timeIndexLabel.layer.masksToBounds = YES;
  33. _timeIndexLabel.textColor = [UIColor whiteColor];
  34. _timeIndexLabel.backgroundColor = HEXCOLOR(0x02d8c9);
  35. _timeIndexLabel.textAlignment = NSTextAlignmentCenter;
  36. _timeIndexLabel.text = @"0";
  37. _timeIndexLabel.font = [UIFont systemFontOfSize:12.0];
  38. _timeIndexLabel.hidden = YES;
  39. [self.contentView addSubview:_timeIndexLabel];
  40. UITapGestureRecognizer * tapPress = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dotapPress:)];
  41. [self.contentView addGestureRecognizer:tapPress];
  42. _messageConent.text = self.msg.content;
  43. }
  44. - (void)dotapPress:(UITapGestureRecognizer *)tap {
  45. if (self.block) {
  46. self.block(self.msg);
  47. }
  48. }
  49. -(void)setCellData{
  50. [super setCellData];
  51. JLBubbleManager *bubbleManager;
  52. if (self.msg.isGroup) {
  53. memberData *data = [[memberData alloc] init];
  54. data.roomId = self.room.roomId;
  55. data = [data getCardNameById:self.msg.fromUserId];
  56. if (data.bubbleFontId.length <= 0) {
  57. bubbleManager = [JLBubbleManager sharedManager];
  58. bubbleManager.id = @"0";
  59. }else {
  60. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:data.bubbleFontId];
  61. }
  62. // NSLog(@"ID--%@---fromUserId%@--%@", data.bubbleFontId,self.msg.fromUserId,bubbleManager);
  63. }else {
  64. // 单聊
  65. // 从朋友表里获取
  66. JXUserObject *user;
  67. if (self.msg.isMySend) {
  68. user = [[JXUserObject sharedInstance] getUserById:MY_USER_ID];
  69. }else {
  70. user = [[JXUserObject sharedInstance] getUserById:self.msg.fromUserId];
  71. }
  72. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:user.bubbleFontId];
  73. }
  74. if (bubbleManager == nil) {
  75. _messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:-1];
  76. _messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:@""];
  77. }else {
  78. _messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:[bubbleManager.code intValue]];
  79. _messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:bubbleManager.color];
  80. }
  81. _messageConent.textColor =[UIColor blackColor];
  82. // 设置显示字体
  83. _messageConent.frame = CGRectMake(0, 0, 200, 20);
  84. if (self.msg.objectId.length > 0) {
  85. _messageConent.atUserIdS = self.msg.objectId;
  86. }
  87. if ([self.msg.isReadDel boolValue] && ([self.msg.fileName length] <= 0 || [self.msg.fileName intValue] <= 0) && !self.msg.isMySend) {
  88. _messageConent.userInteractionEnabled = NO;
  89. _messageConent.text = [NSString stringWithFormat:@"%@ T", Localized(@"JX_ClickAndView")];
  90. // _messageConent.textColor = HEXCOLOR(0x0079FF);
  91. _timeIndexLabel.hidden = YES;
  92. }else {
  93. _messageConent.userInteractionEnabled = YES;
  94. // _messageConent.textColor = HEXCOLOR(0x333333);
  95. // _messageConent.textColor = [UIColor whiteColor];
  96. if ([self.msg.content containsString:@"===jixin"]) {
  97. NSArray *typeArr = [self.msg.content componentsSeparatedByString:@"===jixin"];
  98. _messageConent.text=[typeArr firstObject];
  99. }else{
  100. _messageConent.text = self.msg.content;
  101. }
  102. // NSLog(@"000000%@",self.msg.content);
  103. _timeIndexLabel.hidden = YES;
  104. if (!self.msg.isMySend && [self.msg.fileName isKindOfClass:[NSString class]] && [self.msg.fileName length] > 0 && [self.msg.fileName intValue] > 0) {
  105. self.timeIndexLabel.hidden = NO;
  106. NSString *messageR = [self.msg.content stringByReplacingOccurrencesOfString:@"\r" withString:@""]; //去掉回车键
  107. NSString *messageN = [messageR stringByReplacingOccurrencesOfString:@"\n" withString:@""]; //去掉回车键
  108. NSString *messageText = [messageN stringByReplacingOccurrencesOfString:@" " withString:@""]; //去掉空格
  109. NSMutableAttributedString * textC = [self changeEmjoyText:messageText];
  110. [textC addAttribute:NSFontAttributeName value:SYSFONT(g_constant.chatFont) range:NSMakeRange(0, textC.length)];
  111. CGSize size = [textC boundingRectWithSize:CGSizeMake(_messageConent.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
  112. NSInteger count = size.height / _messageConent.font.lineHeight;
  113. // NSLog(@"countcount === %ld-----%f-----%@",count,[[NSDate date] timeIntervalSince1970],self.msg.fileName);
  114. // NSLog(@"countcount === %ld,,,,%f,,,,%@",count,[[NSDate date] timeIntervalSince1970], self.msg.fileName);
  115. count = count * 10 - ([[NSDate date] timeIntervalSince1970] - [self.msg.fileName longLongValue]);
  116. self.timerIndex = count;
  117. // NSLog(@"countcount1 === %ld",count);
  118. if (count > 0) {
  119. self.timeIndexLabel.text = [NSString stringWithFormat:@"%ld",count];
  120. if (!self.readDelTimer) {
  121. self.readDelTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
  122. }
  123. }else {
  124. self.msg.fileName = @"0";
  125. //阅后即焚通知
  126. [g_notify postNotificationName:kCellReadDelNotification object:self.msg];
  127. [self deleteMsg:self.msg];
  128. }
  129. }
  130. }
  131. [self creatBubbleBg];
  132. }
  133. -(void)creatBubbleBg{
  134. CGSize textSize = _messageConent.frame.size;
  135. int n = textSize.width;
  136. if ([_messageConent.text containsString:@"--【"]) {
  137. kuangkkHHH=65.0;
  138. } //聊天长度反正就是算错了,强行改
  139. int inset = 3;
  140. if(self.msg.isMySend){
  141. self.bubbleBg.frame=CGRectMake(CGRectGetMinX(self.headImage.frame)-INSETS*2-inset*2-n-CHAT_WIDTH_ICON, INSETS,_kuangHHH+ n+INSETS*2+inset*2, textSize.height+INSETS*2);
  142. self.bubbleBgImageView.frame = CGRectMake(0, 0,n+INSETS*2+inset*2, textSize.height+INSETS*2+INSETS);
  143. [_messageConent setFrame:CGRectMake(INSETS*0.4 + 3 +5, 10,_kuangHHH+ n + 5, textSize.height)];
  144. // [_messageConent setFrame:CGRectMake(INSETS*0.4 + 3, INSETS, n + 5, textSize.height+50)];
  145. _timeIndexLabel.frame = CGRectMake(self.bubbleBg.frame.origin.x - 30, self.bubbleBg.frame.origin.y, 20, 20);
  146. }else
  147. {
  148. self.bubbleBg.frame=CGRectMake(CGRectGetMaxX(self.headImage.frame) + CHAT_WIDTH_ICON, INSETS2(self.msg.isGroup)+9, n+INSETS*2+inset*2, textSize.height+INSETS*2);
  149. self.bubbleBgImageView.frame =CGRectMake(0, 2, n+INSETS*2+inset*2, textSize.height+INSETS*2+20);
  150. [_messageConent setFrame:CGRectMake(INSETS + 3, 10, n+5, textSize.height)];
  151. _timeIndexLabel.frame = CGRectMake(CGRectGetMaxX(self.bubbleBg.frame) + 10, self.bubbleBg.frame.origin.y, 20, 20);
  152. // _messageConent.textAlignment = NSTextAlignmentLeft;
  153. }
  154. if (self.msg.isShowTime) {
  155. CGRect frame = self.bubbleBg.frame;
  156. frame.origin.y = self.bubbleBg.frame.origin.y + 40;
  157. self.bubbleBg.frame = frame;
  158. _timeIndexLabel.frame = CGRectMake(_timeIndexLabel.frame.origin.x, self.bubbleBg.frame.origin.y, 20, 20);
  159. }
  160. }
  161. - (void)setBackgroundImage {
  162. [super setBackgroundImage];
  163. if (!self.msg.isMySend && [self.msg.fileName isKindOfClass:[NSString class]] && [self.msg.fileName length] > 0 && [self.msg.fileName intValue] >= 0 && [self.msg.type intValue] == kWCMessageTypeText) {
  164. self.isDidMsgCell = YES;
  165. }
  166. if ([self.msg.isReadDel boolValue] && !self.msg.isMySend && self.isDidMsgCell) {
  167. [self drawReadDelView:YES];
  168. self.isDidMsgCell = NO;
  169. }
  170. }
  171. //复制信息到剪贴板
  172. - (void)myCopy{
  173. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  174. [pasteboard setString:self.msg.content];
  175. }
  176. + (float)getChatCellHeight:(JXMessageObject *)msg {
  177. //NSLog(@"----%@",msg.content);
  178. if ([msg.chatMsgHeight floatValue] > 1) {
  179. if ([msg.content containsString:@"--------------------------------------------------"]) {
  180. kuangkkHHH=65.0;
  181. }
  182. CGFloat chatMsgHeight = [msg.chatMsgHeight floatValue]+kuangkkHHH;
  183. return chatMsgHeight;
  184. }
  185. float n = 0.0;
  186. JXEmoji *messageConent=[[JXEmoji alloc]initWithFrame:CGRectMake(0, 0, 200, 20)];
  187. messageConent.backgroundColor = [UIColor clearColor];
  188. // messageConent.userInteractionEnabled = NO;
  189. messageConent.numberOfLines = 0;
  190. messageConent.lineBreakMode = NSLineBreakByWordWrapping;//UILineBreakModeWordWrap;
  191. JLBubbleManager *bubbleManager;
  192. if (msg.isGroup) {
  193. memberData *data = [[memberData alloc] init];
  194. data.roomId = msg.toId;
  195. data = [data getCardNameById:msg.fromUserId];
  196. if (data.bubbleFontId.length <= 0) {
  197. bubbleManager = [JLBubbleManager sharedManager];
  198. bubbleManager.id = @"0";
  199. }else {
  200. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:data.bubbleFontId];
  201. }
  202. // NSLog(@"ID--%@---fromUserId%@--%@", data.bubbleFontId,self.msg.fromUserId,bubbleManager);
  203. }else {
  204. // 单聊
  205. // 从朋友表里获取
  206. JXUserObject *user;
  207. if (msg.isMySend) {
  208. user = [[JXUserObject sharedInstance] getUserById:MY_USER_ID];
  209. }else {
  210. user = [[JXUserObject sharedInstance] getUserById:msg.fromUserId];
  211. }
  212. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:user.bubbleFontId];
  213. }
  214. if (bubbleManager == nil) {
  215. messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:-1];
  216. messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:@""];
  217. }else {
  218. messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:[bubbleManager.code intValue]];
  219. messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:bubbleManager.color];
  220. }
  221. messageConent.offset = -12;
  222. messageConent.frame = CGRectMake(0, 0, 200, 20);
  223. if ([msg.isReadDel boolValue] && [msg.fileName intValue] <= 0 && !msg.isMySend) {
  224. messageConent.text = [NSString stringWithFormat:@"%@ T", Localized(@"JX_ClickAndView")];
  225. }else {
  226. messageConent.text = msg.content;
  227. }
  228. if (msg.isGroup && !msg.isMySend) {
  229. n = messageConent.frame.size.height+10*3 + 27;
  230. if (msg.isShowTime) {
  231. n=messageConent.frame.size.height+10*3 + 40 + 20;
  232. }
  233. n += GROUP_CHAT_INSET;
  234. }else {
  235. n= messageConent.frame.size.height+10*3 + 10;
  236. if (msg.isShowTime) {
  237. n=messageConent.frame.size.height+10*3 + 40 + 10;
  238. }
  239. }
  240. // NSLog(@"heightForRowAtIndexPath_%d,%d:=%@",indexPath.row,n,_messageConent.text);
  241. if(n<55)
  242. n = 55+10;
  243. if (msg.isShowTime) {
  244. if(n<95)
  245. n = 95+10;
  246. }
  247. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n];
  248. if ([msg.content containsString:@"===jixinJXBigRellV"]){
  249. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n]; //--20
  250. }
  251. if (!msg.isNotUpdateHeight) {
  252. [msg updateChatMsgHeight];
  253. }
  254. // NSLog(@"高度%f--内容高度%f--内容%@", n, messageConent.frame.size.height,msg.content);
  255. return n;
  256. }
  257. -(void)didTouch:(UIButton*)button{
  258. if ([self.msg.isReadDel boolValue] && [self.msg.fileName intValue] <= 0 && !self.msg.isMySend) {
  259. [self.msg sendAlreadyReadMsg];
  260. self.msg.fileName = [NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]];
  261. [self.msg updateFileName];
  262. self.timeIndexLabel.hidden = NO;
  263. _messageConent.text = self.msg.content;
  264. // NSString *messageR = [self.msg.content stringByReplacingOccurrencesOfString:@"\r" withString:@""]; //去掉回车键
  265. // NSString *messageN = [messageR stringByReplacingOccurrencesOfString:@"\n" withString:@""]; //去掉回车键
  266. // NSString *messageText = [messageN stringByReplacingOccurrencesOfString:@" " withString:@""]; //去掉空格
  267. // CGSize size = [messageText boundingRectWithSize:CGSizeMake(_messageConent.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(g_constant.chatFont)} context:nil].size;
  268. // NSInteger count = size.height / _messageConent.font.lineHeight;
  269. // self.msg.fileName = [NSString stringWithFormat:@"%ld", count * 10];
  270. self.isDidMsgCell = YES;
  271. self.msg.chatMsgHeight = [NSString stringWithFormat:@"0"];
  272. [self.msg updateChatMsgHeight];
  273. [g_notify postNotificationName:kCellMessageReadDelNotifaction object:[NSNumber numberWithInt:self.indexNum]];
  274. // self.readDelTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
  275. }
  276. }
  277. - (void)timerAction:(NSTimer *)timer {
  278. if (self.timerIndex <= 0) {
  279. [self.readDelTimer invalidate];
  280. self.readDelTimer = nil;
  281. self.msg.fileName = @"0";
  282. //阅后即焚通知
  283. [g_notify postNotificationName:kCellReadDelNotification object:self.msg];
  284. [self deleteMsg:self.msg];
  285. return;
  286. }
  287. self.timeIndexLabel.text = [NSString stringWithFormat:@"%ld",-- self.timerIndex];
  288. // self.msg.fileName = self.timeIndexLabel.text;
  289. // [self.msg updateFileName];
  290. }
  291. - (void)deleteMsg:(JXMessageObject *)msg{
  292. if ([self.msg.isReadDel boolValue]) {
  293. if ([self.msg.fileName intValue] > 0) {
  294. return;
  295. }
  296. //渐变隐藏
  297. [UIView animateWithDuration:2.f animations:^{
  298. self.bubbleBg.alpha = 0;
  299. self.timeIndexLabel.alpha = 0;
  300. self.readImage.alpha = 0;
  301. self.burnImage.alpha = 0;
  302. } completion:^(BOOL finished) {
  303. //动画结束后删除UI
  304. [self.delegate performSelectorOnMainThread:self.readDele withObject:msg waitUntilDone:NO];
  305. self.bubbleBg.alpha = 1;
  306. self.timeIndexLabel.alpha = 1;
  307. self.readImage.alpha = 1;
  308. self.burnImage.alpha = 1;
  309. }];
  310. }
  311. }
  312. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  313. [super setSelected:selected animated:animated];
  314. // Configure the view for the selected state
  315. }
  316. #pragma mark - 有表情的txt 转换成 含图片的str
  317. - (NSMutableAttributedString *)changeEmjoyText:(NSString *)text {
  318. NSMutableAttributedString *conStr = [[NSMutableAttributedString alloc] init];
  319. NSMutableArray *arr = [NSMutableArray array];
  320. [self getImageRange:text array:arr];
  321. if (arr.count > 1) {
  322. for (NSInteger i = 0; i < arr.count; i ++) {
  323. NSString *str = arr[i];
  324. NSInteger n;
  325. if ([str hasPrefix:@"["]&&[str hasSuffix:@"]"] && [g_faceVC.shortNameArrayE containsObject:str]) {
  326. n = [g_faceVC.shortNameArrayE indexOfObject:str];
  327. NSDictionary *dic = [g_constant.emojiArray objectAtIndex:n];
  328. EmojiTextAttachment *attachment = [[EmojiTextAttachment alloc] init];
  329. attachment.emojiTag = str;
  330. attachment.image = [UIImage imageNamed:dic[@"filename"]];
  331. attachment.bounds = CGRectMake(0, -4, 23, 23);
  332. [conStr appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
  333. }else {
  334. [conStr appendAttributedString:[[NSAttributedString alloc] initWithString:str attributes:@{NSFontAttributeName:self.messageConent.font}]];
  335. }
  336. }
  337. }else {
  338. return [[NSMutableAttributedString alloc] initWithString:text];
  339. }
  340. return conStr;
  341. }
  342. //将表情和文字分开,装进array
  343. -(void)getImageRange:(NSString*)message array: (NSMutableArray*)array {
  344. NSRange range=[message rangeOfString: @"["];
  345. NSRange range1=[message rangeOfString: @"]"];
  346. NSRange atRange = [message rangeOfString:@"@"];
  347. //判断当前字符串是否还有表情的标志。
  348. if (((range.length>0 && range1.length>0) || atRange.length>0) && range1.location > range.location) {
  349. if (range.length>0 && range1.length>0) {
  350. // self.contentEmoji = YES;
  351. // if (range.location > 0) {
  352. // [array addObject:[message substringToIndex:range.location]];
  353. // [array addObject:[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)]];
  354. // NSString *str=[message substringFromIndex:range1.location+1];
  355. // [self getImageRange:str array:array];
  356. // }else {
  357. // NSString *nextstr=[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)];
  358. // //排除文字是“”的
  359. // if (![nextstr isEqualToString:@""]) {
  360. // [array addObject:nextstr];
  361. // NSString *str=[message substringFromIndex:range1.location+1];
  362. // [self getImageRange:str array:array];
  363. // }else {
  364. // return;
  365. // }
  366. // }
  367. if (range.location > 0) {
  368. NSString *str = [message substringToIndex:range.location];
  369. NSString *str1 = [message substringFromIndex:range.location];
  370. [array addObject:str];
  371. [self getImageRange:str1 array:array];
  372. }else {
  373. NSString *emojiString = [message substringWithRange:NSMakeRange(range.location + 1, range1.location - 1)];
  374. BOOL isEmoji = NO;
  375. NSString *str;
  376. NSString *str1;
  377. for (NSMutableDictionary *dic in g_constant.emojiArray) {
  378. NSString *emoji = [dic objectForKey:@"english"];
  379. if ([emoji isEqualToString:emojiString]) {
  380. isEmoji = YES;
  381. break;
  382. }
  383. }
  384. if (isEmoji) {
  385. str = [message substringWithRange:NSMakeRange(range.location, range1.location + 1)];
  386. str1 = [message substringFromIndex:range1.location + 1];
  387. [array addObject:str];
  388. }else{
  389. NSString *posString = [message substringWithRange:NSMakeRange(range.location + 1, range1.location)];
  390. NSRange posRange = [posString rangeOfString:@"["];
  391. if (posRange.location != NSNotFound) {
  392. str = [message substringToIndex:posRange.location + 1];
  393. str1 = [message substringFromIndex:posRange.location + 1];
  394. [array addObject:str];
  395. }else{
  396. str = [message substringToIndex:range1.location + 1];
  397. str1 = [message substringFromIndex:range1.location + 1];
  398. [array addObject:str];
  399. }
  400. }
  401. [self getImageRange:str1 array:array];
  402. }
  403. } else if (atRange.length>0) {
  404. if (atRange.location > 0) {
  405. [array addObject:[message substringToIndex:atRange.location]];
  406. [array addObject:[message substringWithRange:NSMakeRange(atRange.location, 1)]];
  407. NSString *str=[message substringFromIndex:atRange.location+1];
  408. [self getImageRange:str array:array];
  409. }else{
  410. [array addObject:[message substringWithRange:NSMakeRange(atRange.location, 1)]];
  411. NSString *str=[message substringFromIndex:atRange.location+1];
  412. [self getImageRange:str array:array];
  413. }
  414. }else if (message != nil) {
  415. [array addObject:message];
  416. }
  417. }
  418. else if (range.length>0 && range1.length>0 && range1.location < range.location){
  419. NSString *str = [message substringToIndex:range1.location + 1];
  420. NSString *str1 = [message substringFromIndex:range1.location + 1];
  421. [array addObject:str];
  422. [self getImageRange:str1 array:array];
  423. }
  424. else if (message != nil) {
  425. [array addObject:message];
  426. }
  427. }
  428. @end