FaqCell.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // FaqCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/12/10.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "FaqCell.h"
  9. @interface FaqCell()
  10. @property(nonatomic,strong)UIImageView* iv2;
  11. @property(nonatomic,strong)UILabel* textLbl2;
  12. @property(nonatomic,strong)UILabel* detailLbl2;
  13. @property(nonatomic,strong)UILabel* dateLbl;
  14. @property(nonatomic,strong)UILabel* dateLbl2;
  15. @end
  16. @implementation FaqCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization codenon
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. }
  24. +(FaqCell*)cellForTableView:(UITableView*)tableView
  25. {
  26. FaqCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FaqCell"];
  27. if (!cell) {
  28. cell = [[FaqCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FaqCell"];
  29. UILabel* label;
  30. label = [UILabel new];
  31. [cell addSubview:label];
  32. cell.textLbl2 = label;
  33. label = [UILabel new];
  34. [cell addSubview:label];
  35. cell.detailLbl2 = label;
  36. label = [UILabel new];
  37. [cell addSubview:label];
  38. cell.dateLbl = label;
  39. label = [UILabel new];
  40. [cell addSubview:label];
  41. cell.dateLbl2 = label;
  42. UIImageView* iv = [UIImageView new];
  43. [cell addSubview:iv];
  44. cell.iv2 = iv;
  45. [cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
  46. [cell.iv2 setContentMode:UIViewContentModeScaleAspectFit];
  47. [cell.textLabel setTextColor:defGreen];
  48. [cell.textLabel setFont:[UIFont scaleSize:NormalFont]];
  49. [cell.textLbl2 setTextColor:RGB_COLOR(253, 115, 61)];
  50. [cell.textLbl2 setFont:[UIFont scaleSize:NormalFont]];
  51. [cell.detailTextLabel setTextColor:contentTextColor];
  52. [cell.detailTextLabel setFont:[UIFont scaleSize:14]];
  53. [cell.detailLbl2 setTextColor:contentTextColor];
  54. [cell.detailLbl2 setFont:[UIFont scaleSize:14]];
  55. [cell.dateLbl setTextColor:contentTextColor];
  56. [cell.dateLbl setFont:[UIFont scaleSize:14]];
  57. [cell.dateLbl2 setTextColor:contentTextColor];
  58. [cell.dateLbl2 setFont:[UIFont scaleSize:14]];
  59. cell.detailTextLabel.numberOfLines = 0;
  60. cell.detailLbl2.numberOfLines = 0;
  61. [cell.dateLbl setTextAlignment:NSTextAlignmentRight];
  62. [cell.dateLbl2 setTextAlignment:NSTextAlignmentRight];
  63. }
  64. return cell;
  65. }
  66. -(void)setModel:(NSDictionary *)model
  67. {
  68. _model = model;
  69. NSString* str;
  70. [self.imageView setImage:[UIImage imageNamed:@"faqImg0.png"]];
  71. [self.iv2 setImage:[UIImage imageNamed:@"faqImg1.png"]];
  72. NSString *nameString = model[@"userName"];
  73. if (nameString.length < 1) {
  74. nameString = @"匿名";
  75. }
  76. [self.textLabel setText:nameString];
  77. [self.dateLbl setText:model[@"crDate"]];
  78. if (model[@"answerDate"]) {
  79. [self.dateLbl2 setText:model[@"answerDate"]];
  80. }else{
  81. [self.dateLbl2 setText:@""];
  82. }
  83. [self.detailTextLabel setText:model[@"content"]];
  84. [self.textLbl2 setText:@"驾校回复"];
  85. str = model[@"answerContent"];
  86. if (!str) {
  87. str = @"等待驾校回复中...";
  88. }
  89. [self.detailLbl2 setText:str];
  90. }
  91. -(void)setSuggestModel:(NSDictionary *)suggestModel
  92. {
  93. _suggestModel = suggestModel;
  94. [self.imageView setImage:[UIImage imageNamed:@""]];
  95. NSString *path = defUser.userDict[@"photo"];
  96. if (path && ![path hasPrefix:@"http"]){
  97. path = [imgPreFix stringByAppendingString:path];
  98. }
  99. if (!path || path.length < 1) {
  100. path = @"";
  101. }
  102. [self.imageView sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:@"faqImg0.png"]];
  103. [self.iv2 setImage:[UIImage imageNamed:@"faqImg2.png"]];
  104. [self.textLabel setText:@"其它建议"];
  105. [self.dateLbl setText:suggestModel[@"ANSWERTIME"]];
  106. [self.detailTextLabel setText:suggestModel[@"ANSWERCONTENT"]];
  107. [self.dateLbl2 setText:suggestModel[@"REPLYTIME"]];
  108. NSString *str = suggestModel[@"REPLYUSER"];
  109. if (!str || str.length < 1) {
  110. str = @"暂无回复";
  111. }
  112. [self.textLbl2 setText:str];
  113. str = suggestModel[@"REPLYCONTENT"];
  114. if (!str || str.length < 1) {
  115. str = @"等待回复中...";
  116. }
  117. [self.detailLbl2 setText:str];
  118. }
  119. -(void)layoutSubviews
  120. {
  121. [super layoutSubviews];
  122. CGFloat wid = kSize.width;
  123. CGFloat x,y,w,h,bd;
  124. bd = 10;
  125. x = bd*2;
  126. y = bd;
  127. w = h = 40;
  128. [self.imageView setFrame:CGRectMake(x, y, w, h)];
  129. x += w+bd;
  130. y = 0;
  131. w = wid - x;
  132. h = 35;
  133. [self.textLabel setFrame:CGRectMake(x, y, w, h)];
  134. [self.dateLbl setFrame:CGRectMake(x-bd, y, w, h)];
  135. y += h;
  136. w -= 2*bd;
  137. h = [self.detailTextLabel.text heightForWid:w Font:14];
  138. if (h < 25) {
  139. h = 25;
  140. }
  141. [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
  142. y += h + 2*bd;
  143. x = bd*2;
  144. w = h = 40;
  145. [self.iv2 setFrame:CGRectMake(x, y, w, h)];
  146. x += w+bd;
  147. y -= bd;
  148. w = wid - x;
  149. h = 35;
  150. [self.textLbl2 setFrame:CGRectMake(x, y, w, h)];
  151. [self.dateLbl2 setFrame:CGRectMake(x-bd, y, w, h)];
  152. y += h;
  153. w -= 2*bd;
  154. h = [self.detailLbl2.text heightForWid:w Font:14];
  155. if (h < 25) {
  156. h = 25;
  157. }
  158. [self.detailLbl2 setFrame:CGRectMake(x, y, w, h)];
  159. }
  160. @end