WD_DetailDevCell.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //
  2. // WD_DetailDevCell.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/6/20.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "WD_DetailDevCell.h"
  9. @interface WD_DetailDevCell ()
  10. {
  11. UILabel * _licNumLab;
  12. UILabel * _schLab;
  13. UILabel * _addressLab;
  14. UILabel * _isConnectLab;
  15. UILabel * _simLab;
  16. UILabel * _registLab;
  17. UILabel * _typeLab;
  18. UIView *_view;
  19. UIView *_bottomView;
  20. }
  21. @end
  22. @implementation WD_DetailDevCell
  23. +(WD_DetailDevCell *)cellForTableView:(UITableView *)tableView{
  24. WD_DetailDevCell * cell = [tableView dequeueReusableCellWithIdentifier:@"WD_DetailDevCell"];
  25. if (!cell) {
  26. cell = [[WD_DetailDevCell alloc]initWithStyle:0 reuseIdentifier:@"WD_DetailDevCell"];
  27. }
  28. return cell;
  29. }
  30. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  31. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  32. if (self) {
  33. self.tintColor = COLOR_THEME;
  34. _view = [UIView new];
  35. _view.backgroundColor = KBackGroundColor;
  36. [self.contentView addSubview:_view];
  37. _bottomView = [UIView new];
  38. _bottomView.backgroundColor = KBackGroundColor;
  39. [self.contentView addSubview:_bottomView];
  40. //
  41. NSMutableArray *mArr = [NSMutableArray new];
  42. for (int i=0; i<7; i++) {
  43. UILabel *lab = [[UILabel alloc]init];
  44. lab.font = [UIFont systemFontOfSize:14];
  45. [mArr addObject:lab];
  46. [self.contentView addSubview:lab];
  47. }
  48. _isConnectLab = mArr[0];
  49. _registLab = mArr[1];
  50. _licNumLab = mArr[2];
  51. _schLab = mArr[3];
  52. _addressLab = mArr[4];
  53. _simLab = mArr[5];
  54. _typeLab = mArr[6];
  55. _isConnectLab.textAlignment = NSTextAlignmentRight;
  56. _registLab.textAlignment = NSTextAlignmentRight;
  57. _licNumLab.textColor = COLOR_THEME;
  58. }
  59. return self;
  60. }
  61. -(void)setDic:(NSDictionary *)dic{
  62. _dic = dic;
  63. _licNumLab.text = [NSString stringWithFormat:@"终端号:%@",dic[@"CARNUM"]];
  64. _schLab.text = [NSString stringWithFormat:@"所属驾校:%@",dic[@"SCHOOLNAME"]];
  65. _addressLab.text = [NSString stringWithFormat:@"所属地区:%@%@",dic[@"DQMC"],dic[@"QXMC"]];
  66. _simLab.text = [NSString stringWithFormat:@"联系电话:%@",dic[@"SIM"]];
  67. // NSString *status = [NSString stringWithFormat:@"%@",dic[@"ISCONNECT"]];
  68. // NSString *isConnect = [status isEqualToString:@"1"] ? @"在线" : @"离线";
  69. _isConnectLab.text = [NSString stringWithFormat:@"车牌号:%@",dic[@"LICNUM"]];
  70. NSString *regStatus = [NSString stringWithFormat:@"%@",dic[@"REGSTATUS"]];
  71. NSString *isReg = [regStatus isEqualToString:@"1"] ? @"已注册" : @"未注册";
  72. _registLab.text = [NSString stringWithFormat:@"%@",isReg];
  73. NSString *terStatus = [NSString stringWithFormat:@"%@",dic[@"TERMTYPE"]];
  74. NSString *isStu = [terStatus isEqualToString:@"1"] ? @"学员" : @"教练";
  75. //1:车载计程计时终端; 2:课堂教学计时终端; 3:模拟训练计时终端; 0 教练APP设备 10学员APP设备
  76. switch ([terStatus integerValue]) {
  77. case 0:
  78. isStu = @"教练APP设备";
  79. break;
  80. case 1:
  81. isStu = @"车载计程计时终端";
  82. break;
  83. case 2:
  84. isStu = @"课堂教学计时终端";
  85. break;
  86. case 3:
  87. isStu = @"模拟训练计时终端";
  88. break;
  89. case 10:
  90. isStu = @"学员APP设备";
  91. break;
  92. default:
  93. break;
  94. }
  95. _typeLab.text = [NSString stringWithFormat:@"终端类型:%@",isStu];
  96. }
  97. -(void)layoutSubviews{
  98. [super layoutSubviews];
  99. CGFloat wid = self.width;
  100. CGFloat x,y,w,h,bd;
  101. x = -50;
  102. w = wid+50;
  103. y = 0;
  104. h = 10;
  105. _view.frame = setDIYFrame;
  106. x = 10;
  107. w = [_licNumLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width+10;
  108. y = 20;
  109. h = 17;
  110. bd = 10;
  111. _licNumLab.frame = setDIYFrame;
  112. // w = wid-20;
  113. // _registLab.frame = setDIYFrame;
  114. y += h+bd;
  115. w = [_typeLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width;
  116. _typeLab.frame = setDIYFrame;
  117. w = wid-20;
  118. _isConnectLab.frame = setDIYFrame;
  119. y += h+bd;
  120. _schLab.frame = setDIYFrame;
  121. y += h+bd;
  122. _addressLab.frame = setDIYFrame;
  123. y += h+bd;
  124. _simLab.frame = setDIYFrame;
  125. x = -50;
  126. w = wid+50;
  127. y +=10+h;
  128. h = 10;
  129. _bottomView.frame = setDIYFrame;
  130. //165
  131. }
  132. - (void)awakeFromNib {
  133. [super awakeFromNib];
  134. // Initialization code
  135. }
  136. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  137. [super setSelected:selected animated:animated];
  138. // Configure the view for the selected state
  139. }
  140. @end