EvaListCell.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. //
  2. // EvaListCell.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/6/15.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "EvaListCell.h"
  9. #import "RatingBar.h"
  10. @interface EvaListCell()
  11. {
  12. UILabel *_coach;
  13. UILabel *_school;
  14. UILabel *_srvmanner;
  15. UILabel *_star;
  16. UILabel *_subject;
  17. UILabel *_teachLevel;
  18. UILabel *_student;
  19. UILabel *_time;
  20. UIView *_view;
  21. RatingBar *_starBar;
  22. UIView * _srvmannerView;
  23. }
  24. @end
  25. @implementation EvaListCell
  26. +(EvaListCell *)cellForTabelView:(UITableView *)tableView{
  27. EvaListCell* cell = [tableView dequeueReusableCellWithIdentifier:@"EvaListCell"];
  28. if (!cell) {
  29. cell = [[EvaListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EvaListCell"];
  30. }
  31. return cell;
  32. }
  33. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  34. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  35. self.selectionStyle = UITableViewCellSelectionStyleNone;
  36. NSArray * textArr = @[@"教练名字",@"机构名字",@"srvmanner",@"星级",@"科目",@"评价内容",@"时间",@"学员"];
  37. NSMutableArray * labArr = [NSMutableArray new];
  38. //
  39. for (int i=0; i<textArr.count; i++) {
  40. UILabel * lab = [[UILabel alloc]init];
  41. lab.textColor = [UIColor blackColor];
  42. lab.textAlignment = NSTextAlignmentLeft;
  43. lab.font = [UIFont systemFontOfSize:14];
  44. [self.contentView addSubview:lab];
  45. [labArr addObject:lab];
  46. }
  47. _coach = labArr[0];
  48. _school = labArr[1];
  49. _srvmanner = labArr[2];
  50. _star = labArr[3];
  51. _subject = labArr[4];
  52. _teachLevel = labArr[5];
  53. _time = labArr[6];
  54. _student = labArr[7];
  55. _time.textAlignment = NSTextAlignmentRight;
  56. _time.textColor = [UIColor lightGrayColor];
  57. _time.font = [UIFont systemFontOfSize:12];
  58. _teachLevel.numberOfLines = 0;
  59. _srvmanner.numberOfLines = 0;
  60. _subject.textAlignment = NSTextAlignmentRight;
  61. _starBar = [[RatingBar alloc]initWithFrame:CGRectMake(0, 0, 70, 17) Flag:YES];
  62. _starBar.enable = NO;
  63. [self.contentView addSubview:_starBar];
  64. //
  65. _view = [UIView new];
  66. _view.backgroundColor = KBackGroundColor;
  67. [self.contentView addSubview:_view];
  68. //
  69. _srvmannerView = [UIView new];
  70. [self.contentView addSubview:_srvmannerView];
  71. }
  72. return self;
  73. }
  74. - (void)layoutSubviews {
  75. [super layoutSubviews];
  76. [super layoutSubviews];
  77. CGFloat wid = self.width;
  78. CGFloat x,y,w,h,bd;
  79. x = 0;
  80. w = wid;
  81. y = 0;
  82. h = 20;
  83. _view.frame = KSetDIYFrame;
  84. y += 5;
  85. x = 20;
  86. y += h;
  87. bd = 5;
  88. w = wid - 40;
  89. h = 17;
  90. y += bd;
  91. _coach.frame = KSetDIYFrame;
  92. _time.frame = KSetDIYFrame;
  93. y += h+bd;
  94. h = 17;
  95. _school.frame = KSetDIYFrame;
  96. if (_time.frame.size.height == 0) {
  97. _time.frame = KSetDIYFrame;
  98. }
  99. y += h;
  100. h = [_teachLevel.text heightForWid:w Font:14];
  101. if (h != 0) {
  102. y += bd;
  103. }
  104. _teachLevel.frame = KSetDIYFrame;
  105. y += h;
  106. if (_srvmanner.text.length != 0) {
  107. y += bd;
  108. h = 17;
  109. }else{
  110. h = 0;
  111. }
  112. _srvmannerView.frame = KSetDIYFrame;
  113. y += h+bd;
  114. h = 17;
  115. _subject.frame = KSetDIYFrame;
  116. w = 70;
  117. _star.frame = KSetDIYFrame;
  118. x += w;
  119. y += 3;
  120. w = 80;
  121. _starBar.frame = KSetDIYFrame;
  122. // y += h;
  123. // _student.frame = KSetDIYFrame;
  124. }
  125. - (void)updateWithDic:(NSDictionary *)dic {
  126. //NSArray * textArr = @[@"教练名字",@"机构名字",@"srvmanner",@"星级",@"科目",@"评价内容",@"时间",@"学员"];
  127. NSString *type = [NSString stringWithFormat:@"%@",dic[@"TYPE"]];
  128. if ([type isEqualToString:@"1"]) {
  129. _coach.text = [NSString stringWithFormat:@"被评价教练 :%@",dic[@"OBJNAME"]];
  130. _school.text = [NSString stringWithFormat:@"所属驾校 :%@",dic[@"SCHNAME"]];
  131. }else{
  132. _coach.text = @"";
  133. _school.text = [NSString stringWithFormat:@"被评价驾校 :%@",dic[@"OBJNAME"]];
  134. }
  135. for (UIView * subV in _srvmannerView.subviews) {
  136. [subV removeFromSuperview];
  137. }
  138. if ([dic[@"EI_SRVMANNER"] length] != 0) {
  139. _srvmanner.text = dic[@"EI_SRVMANNER"];
  140. NSArray * array = [dic[@"EI_SRVMANNER"] componentsSeparatedByString:@","];
  141. [self createLabViewsWithArray:array];
  142. }else{
  143. _srvmanner.text = @"";
  144. }
  145. if ([dic[@"EI_TEACHLEVEL"] length] != 0) {
  146. _teachLevel.text = [NSString stringWithFormat:@"评价内容 :%@",dic[@"EI_TEACHLEVEL"]];
  147. }else{
  148. _teachLevel.text = @"";
  149. }
  150. _star.text = [NSString stringWithFormat:@"评价星级 :"];
  151. _starBar.starNumber = [[NSString stringWithFormat:@"%@",dic[@"STAR"]] integerValue];
  152. NSString * kemu = @"";
  153. switch ([[NSString stringWithFormat:@"%@",dic[@"PART"]] integerValue]) {
  154. case 1:
  155. kemu = @"一";
  156. break;
  157. case 2:
  158. kemu = @"二";
  159. break;
  160. case 3:
  161. kemu = @"三";
  162. break;
  163. case 4:
  164. kemu = @"四";
  165. break;
  166. default:
  167. break;
  168. }
  169. _subject.text = [NSString stringWithFormat:@"培训科目 :科目%@",kemu];
  170. _time.text = [NSString stringWithFormat:@"%@",dic[@"CRTIME"]];
  171. _student.text = [NSString stringWithFormat:@"学员 :%@",dic[@"STUDENGNAME"]];
  172. }
  173. -(void)createLabViewsWithArray:(NSArray *)array{
  174. //lableview
  175. UILabel * lable;
  176. CGFloat x = 0;
  177. CGFloat y = 0;
  178. CGFloat w = 0;
  179. CGFloat h = 17;
  180. CGFloat bd = 20;
  181. for (int i=0;i<array.count;i++) {
  182. NSString * contentStr = array[i];
  183. CGSize size =[contentStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}];
  184. w = size.width;
  185. lable = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  186. x += bd+w;
  187. lable .text = contentStr;
  188. lable.textColor = RQMianColor;
  189. lable.font = [UIFont systemFontOfSize:13];
  190. lable.textAlignment = NSTextAlignmentCenter;
  191. lable.layer.borderWidth = 0.5;
  192. lable.layer.borderColor = RQMianColor.CGColor;
  193. [_srvmannerView addSubview:lable];
  194. }
  195. }
  196. - (void)awakeFromNib {
  197. [super awakeFromNib];
  198. // Initialization code
  199. }
  200. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  201. [super setSelected:selected animated:animated];
  202. // Configure the view for the selected state
  203. }
  204. @end