// // WD_DetailDevCell.m // LNManager // // Created by EchoShacolee on 2017/6/20. // Copyright © 2017年 lee. All rights reserved. // #import "WD_DetailDevCell.h" @interface WD_DetailDevCell () { UILabel * _licNumLab; UILabel * _schLab; UILabel * _addressLab; UILabel * _isConnectLab; UILabel * _simLab; UILabel * _registLab; UILabel * _typeLab; UIView *_view; UIView *_bottomView; } @end @implementation WD_DetailDevCell +(WD_DetailDevCell *)cellForTableView:(UITableView *)tableView{ WD_DetailDevCell * cell = [tableView dequeueReusableCellWithIdentifier:@"WD_DetailDevCell"]; if (!cell) { cell = [[WD_DetailDevCell alloc]initWithStyle:0 reuseIdentifier:@"WD_DetailDevCell"]; } return cell; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.tintColor = COLOR_THEME; _view = [UIView new]; _view.backgroundColor = KBackGroundColor; [self.contentView addSubview:_view]; _bottomView = [UIView new]; _bottomView.backgroundColor = KBackGroundColor; [self.contentView addSubview:_bottomView]; // NSMutableArray *mArr = [NSMutableArray new]; for (int i=0; i<7; i++) { UILabel *lab = [[UILabel alloc]init]; lab.font = [UIFont systemFontOfSize:14]; [mArr addObject:lab]; [self.contentView addSubview:lab]; } _isConnectLab = mArr[0]; _registLab = mArr[1]; _licNumLab = mArr[2]; _schLab = mArr[3]; _addressLab = mArr[4]; _simLab = mArr[5]; _typeLab = mArr[6]; _isConnectLab.textAlignment = NSTextAlignmentRight; _registLab.textAlignment = NSTextAlignmentRight; _licNumLab.textColor = COLOR_THEME; } return self; } -(void)setDic:(NSDictionary *)dic{ _dic = dic; _licNumLab.text = [NSString stringWithFormat:@"终端号:%@",dic[@"CARNUM"]]; _schLab.text = [NSString stringWithFormat:@"所属驾校:%@",dic[@"SCHOOLNAME"]]; _addressLab.text = [NSString stringWithFormat:@"所属地区:%@%@",dic[@"DQMC"],dic[@"QXMC"]]; _simLab.text = [NSString stringWithFormat:@"联系电话:%@",dic[@"SIM"]]; // NSString *status = [NSString stringWithFormat:@"%@",dic[@"ISCONNECT"]]; // NSString *isConnect = [status isEqualToString:@"1"] ? @"在线" : @"离线"; _isConnectLab.text = [NSString stringWithFormat:@"车牌号:%@",dic[@"LICNUM"]]; NSString *regStatus = [NSString stringWithFormat:@"%@",dic[@"REGSTATUS"]]; NSString *isReg = [regStatus isEqualToString:@"1"] ? @"已注册" : @"未注册"; _registLab.text = [NSString stringWithFormat:@"%@",isReg]; NSString *terStatus = [NSString stringWithFormat:@"%@",dic[@"TERMTYPE"]]; NSString *isStu = [terStatus isEqualToString:@"1"] ? @"学员" : @"教练"; //1:车载计程计时终端; 2:课堂教学计时终端; 3:模拟训练计时终端; 0 教练APP设备 10学员APP设备 switch ([terStatus integerValue]) { case 0: isStu = @"教练APP设备"; break; case 1: isStu = @"车载计程计时终端"; break; case 2: isStu = @"课堂教学计时终端"; break; case 3: isStu = @"模拟训练计时终端"; break; case 10: isStu = @"学员APP设备"; break; default: break; } _typeLab.text = [NSString stringWithFormat:@"终端类型:%@",isStu]; } -(void)layoutSubviews{ [super layoutSubviews]; CGFloat wid = self.width; CGFloat x,y,w,h,bd; x = -50; w = wid+50; y = 0; h = 10; _view.frame = setDIYFrame; x = 10; w = [_licNumLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width+10; y = 20; h = 17; bd = 10; _licNumLab.frame = setDIYFrame; // w = wid-20; // _registLab.frame = setDIYFrame; y += h+bd; w = [_typeLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width; _typeLab.frame = setDIYFrame; w = wid-20; _isConnectLab.frame = setDIYFrame; y += h+bd; _schLab.frame = setDIYFrame; y += h+bd; _addressLab.frame = setDIYFrame; y += h+bd; _simLab.frame = setDIYFrame; x = -50; w = wid+50; y +=10+h; h = 10; _bottomView.frame = setDIYFrame; //165 } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end