// // DeveceTableCell.m // Haishenghai-master // // Created by GG on 2019/1/5. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved. // #import "DeveceTableCell.h" #define ScreenWidth [UIScreen mainScreen].bounds.size.width #define ScreenHeight [UIScreen mainScreen].bounds.size.height @implementation DeveceTableCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { //另一种写法 for (int i=0; i<4; i++) { _titleLabel = [[UILabel alloc]init]; _titleLabel.frame = CGRectMake(10+(ScreenWidth/2)*(i/2), 5+(30)*(i%2), 75, 30); _titleLabel.tag = i+1; if (_titleLabel.tag==1) { _titleLabel.text = @"设备名称:"; _titleLabel.font = [UIFont systemFontOfSize:14]; }else if (_titleLabel.tag==2) { _titleLabel.text = @"位 置:"; _titleLabel.font = [UIFont systemFontOfSize:14]; }else if (_titleLabel.tag==3) { _titleLabel.text = @"编号:"; _titleLabel.font = [UIFont systemFontOfSize:14]; }else if (_titleLabel.tag==4) { _titleLabel.text = @"状态:"; _titleLabel.font = [UIFont systemFontOfSize:14]; } [self.contentView addSubview:_titleLabel]; } _nameLabel = [[UILabel alloc]init]; _nameLabel.frame = CGRectMake(75, 5,ScreenWidth/2-60 , 30); _nameLabel.textColor = [UIColor blackColor]; _nameLabel.font = [UIFont systemFontOfSize:14]; [self.contentView addSubview:_nameLabel]; _numberLabel = [[UILabel alloc]init]; _numberLabel.frame = CGRectMake(65+(ScreenWidth/2-20), 5,ScreenWidth/2-40 , 30); _numberLabel.textColor = [UIColor blackColor]; _numberLabel.font = [UIFont systemFontOfSize:14]; [self.contentView addSubview:_numberLabel]; _locationLabel = [[UILabel alloc]init]; _locationLabel.frame = CGRectMake(75, 35,ScreenWidth/2-60 , 30); _locationLabel.textColor = [UIColor blackColor]; _locationLabel.font = [UIFont systemFontOfSize:14]; [self.contentView addSubview:_locationLabel]; _stateLabel = [[UILabel alloc]init]; _stateLabel.frame = CGRectMake(75+(ScreenWidth/2-20), 35,ScreenWidth/2-60 , 30); _stateLabel.textColor = [UIColor blackColor]; _stateLabel.font = [UIFont systemFontOfSize:14]; [self.contentView addSubview:_stateLabel]; } return self; } -(void)setListModel:(deveceListModel *)listModel{ // _listModel = listModel; // _nameLabel.text = listModel.type_exp; // //服务器返回Null报错 // _locationLabel.text = listModel.deployment; // _numberLabel.text = listModel.deviceid; // if ([listModel.state isEqualToNumber:[NSNumber numberWithInt:0]]) { // _stateLabel.text = @"正常"; // _stateLabel.textColor = [UIColor blueColor]; // } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end