DeveceTableCell.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // DeveceTableCell.m
  3. // Haishenghai-master
  4. //
  5. // Created by GG on 2019/1/5.
  6. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "DeveceTableCell.h"
  9. #define ScreenWidth [UIScreen mainScreen].bounds.size.width
  10. #define ScreenHeight [UIScreen mainScreen].bounds.size.height
  11. @implementation DeveceTableCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. // Initialization code
  15. }
  16. -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. //另一种写法
  19. for (int i=0; i<4; i++) {
  20. _titleLabel = [[UILabel alloc]init];
  21. _titleLabel.frame = CGRectMake(10+(ScreenWidth/2)*(i/2), 5+(30)*(i%2), 75, 30);
  22. _titleLabel.tag = i+1;
  23. if (_titleLabel.tag==1) {
  24. _titleLabel.text = @"设备名称:";
  25. _titleLabel.font = [UIFont systemFontOfSize:14];
  26. }else if (_titleLabel.tag==2) {
  27. _titleLabel.text = @"位 置:";
  28. _titleLabel.font = [UIFont systemFontOfSize:14];
  29. }else if (_titleLabel.tag==3) {
  30. _titleLabel.text = @"编号:";
  31. _titleLabel.font = [UIFont systemFontOfSize:14];
  32. }else if (_titleLabel.tag==4) {
  33. _titleLabel.text = @"状态:";
  34. _titleLabel.font = [UIFont systemFontOfSize:14];
  35. }
  36. [self.contentView addSubview:_titleLabel];
  37. }
  38. _nameLabel = [[UILabel alloc]init];
  39. _nameLabel.frame = CGRectMake(75, 5,ScreenWidth/2-60 , 30);
  40. _nameLabel.textColor = [UIColor blackColor];
  41. _nameLabel.font = [UIFont systemFontOfSize:14];
  42. [self.contentView addSubview:_nameLabel];
  43. _numberLabel = [[UILabel alloc]init];
  44. _numberLabel.frame = CGRectMake(65+(ScreenWidth/2-20), 5,ScreenWidth/2-40 , 30);
  45. _numberLabel.textColor = [UIColor blackColor];
  46. _numberLabel.font = [UIFont systemFontOfSize:14];
  47. [self.contentView addSubview:_numberLabel];
  48. _locationLabel = [[UILabel alloc]init];
  49. _locationLabel.frame = CGRectMake(75, 35,ScreenWidth/2-60 , 30);
  50. _locationLabel.textColor = [UIColor blackColor];
  51. _locationLabel.font = [UIFont systemFontOfSize:14];
  52. [self.contentView addSubview:_locationLabel];
  53. _stateLabel = [[UILabel alloc]init];
  54. _stateLabel.frame = CGRectMake(75+(ScreenWidth/2-20), 35,ScreenWidth/2-60 , 30);
  55. _stateLabel.textColor = [UIColor blackColor];
  56. _stateLabel.font = [UIFont systemFontOfSize:14];
  57. [self.contentView addSubview:_stateLabel];
  58. }
  59. return self;
  60. }
  61. -(void)setListModel:(deveceListModel *)listModel{
  62. // _listModel = listModel;
  63. // _nameLabel.text = listModel.type_exp;
  64. // //服务器返回Null报错
  65. // _locationLabel.text = listModel.deployment;
  66. // _numberLabel.text = listModel.deviceid;
  67. // if ([listModel.state isEqualToNumber:[NSNumber numberWithInt:0]]) {
  68. // _stateLabel.text = @"正常";
  69. // _stateLabel.textColor = [UIColor blueColor];
  70. // }
  71. }
  72. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  73. [super setSelected:selected animated:animated];
  74. // Configure the view for the selected state
  75. }
  76. @end