detailmodel.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // detailmodel.m
  3. // YBVideo
  4. //
  5. // Created by 王敏欣 on 2017/9/6.
  6. // Copyright © 2017年 cat. All rights reserved.
  7. //
  8. #import "detailmodel.h"
  9. @implementation detailmodel
  10. -(instancetype)initWithDic:(NSDictionary *)subdic{
  11. self = [super init];
  12. if (self) {
  13. _at_info = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"at_info"]];
  14. _avatar_thumb = [NSString stringWithFormat:@"%@",[[subdic valueForKey:@"userinfo"] valueForKey:@"avatar"]];
  15. _user_nickname = [NSString stringWithFormat:@"%@",[[subdic valueForKey:@"userinfo"] valueForKey:@"user_nickname"]];
  16. _ID = [NSString stringWithFormat:@"%@",[[subdic valueForKey:@"userinfo"] valueForKey:@"id"]];
  17. _touid = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"touid"]];
  18. _datetime = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"datetime"]];
  19. _likes = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"likes"]];
  20. _islike = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"islike"]];
  21. _touserinfo = [subdic valueForKey:@"touserinfo"];
  22. _tocommentinfo = [subdic valueForKey:@"tocommentinfo"];
  23. _parentid = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"id"]];
  24. _isvoice = minstr([subdic valueForKey:@"type"]);
  25. _voiceUrl = minstr([subdic valueForKey:@"voice"]);
  26. _voiceTime = minstr([subdic valueForKey:@"length"]);
  27. if ([_touid intValue] > 0) {
  28. _content = [NSString stringWithFormat:@"%@%@:%@",YZMsg(@"回复"),[_touserinfo valueForKey:@"user_nickname"],[subdic valueForKey:@"content"]];
  29. }else{
  30. _content = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"content"]];
  31. }
  32. [self setmyframe:nil];
  33. }
  34. return self;
  35. }
  36. -(void)setmyframe:(detailmodel *)model{
  37. //判断是不是回复的回复
  38. NSString *reply1 = [NSString stringWithFormat:@"%@ %@",_content,_datetime];
  39. CGSize size = [reply1 boundingRectWithSize:CGSizeMake(_window_width - 120, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
  40. if ([_isvoice isEqual:@"1"]) {
  41. _contentRect = CGRectMake(26,50, size.width, size.height);
  42. }else{
  43. _contentRect = CGRectMake(26,26, size.width, size.height);
  44. }
  45. _rowH = MAX(0, CGRectGetMaxY(_contentRect)) + 5;
  46. // int touid = [_touid intValue];
  47. //
  48. // if (touid>0) {
  49. // NSString *reply1 = [NSString stringWithFormat:@"回复%@:%@",[_touserinfo valueForKey:@"user_nickname"],_content];
  50. // CGSize size = [reply1 boundingRectWithSize:CGSizeMake(_window_width - 120, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
  51. // _contentRect = CGRectMake(50,55, size.width+20, size.height);
  52. // NSString *reply = [NSString stringWithFormat:@"%@:%@",[_touserinfo valueForKey:@"user_nickname"],[_tocommentinfo valueForKey:@"content"]];
  53. // CGSize size2 = [reply boundingRectWithSize:CGSizeMake(_window_width - 120, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
  54. // _ReplyRect = CGRectMake(0, 20, size2.width+20, size2.height);
  55. // _rowH = MAX(0, CGRectGetMaxY(_ReplyRect)) + 15;
  56. // }
  57. // else{
  58. // CGSize size = [_content boundingRectWithSize:CGSizeMake(_window_width - 120, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
  59. // _contentRect = CGRectMake(0,20, size.width, size.height);
  60. // _ReplyRect = CGRectMake(0, 0, 0, 0);
  61. // _rowH = MAX(0, CGRectGetMaxY(_contentRect)) + 15;
  62. // }
  63. }
  64. +(instancetype)modelWithDic:(NSDictionary *)subdic{
  65. detailmodel *model = [[detailmodel alloc]initWithDic:subdic];
  66. return model;
  67. }
  68. @end