YXDeviceInfoViewController.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // YXDeviceInfoViewController.m
  3. // Temperature
  4. //
  5. // Created by TC on 2025/2/22.
  6. //
  7. #import "YXDeviceInfoViewController.h"
  8. #import "YXDeviceInfoCell.h"
  9. @interface YXDeviceInfoViewController ()<UITableViewDataSource,UITableViewDelegate>
  10. @property (weak, nonatomic) UITableView *tableView;
  11. @property (copy, nonatomic) NSArray *dataArray;
  12. @end
  13. @implementation YXDeviceInfoViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.navigationItem.title = @"设备信息";
  17. self.view.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"];
  18. self.dataArray = @[
  19. @"版本号",@"运行时长",@"运行记录",@"耗材提醒"
  20. ];
  21. [self createTableView];
  22. }
  23. -(void)createTableView
  24. {
  25. UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(15, 0, self.view.frame.size.width - 30, self.view.frame.size.height - kNavHeight - kTabbarHeight) style:UITableViewStyleGrouped];
  26. tableView.delegate = self;
  27. tableView.dataSource = self;
  28. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  29. [tableView registerNib:[UINib nibWithNibName:@"YXDeviceInfoCell" bundle:nil] forCellReuseIdentifier:@"myDeviceInfoCellID"];
  30. tableView.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"];
  31. [self.view addSubview:tableView];
  32. self.tableView = tableView;
  33. tableView.layer.cornerRadius = 8;
  34. [self createTableHeaderView];
  35. }
  36. -(void)createTableHeaderView
  37. {
  38. UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 10)];
  39. headerView.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"];
  40. self.tableView.tableHeaderView = headerView;
  41. }
  42. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  43. {
  44. return 1;
  45. }
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  47. {
  48. return self.dataArray.count;
  49. }
  50. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  51. {
  52. YXDeviceInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myDeviceInfoCellID" forIndexPath:indexPath];
  53. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  54. NSString *title = self.dataArray[indexPath.row];
  55. cell.titleLabel.text = title;
  56. if (indexPath.row == 0) {
  57. cell.detailLabel.hidden = NO;
  58. cell.detailLabel.text = @"2024-02-23 v2.3";
  59. } else if (indexPath.row == 1) {
  60. cell.detailLabel.hidden = NO;
  61. cell.detailLabel.text = @"2小时";
  62. }else{
  63. cell.detailLabel.hidden = YES;
  64. }
  65. return cell;
  66. }
  67. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  68. {
  69. }
  70. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  71. {
  72. UIView *headerView = [[UIView alloc]init];
  73. return headerView;
  74. }
  75. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  76. {
  77. UIView *footerView = [[UIView alloc]init];
  78. return footerView;
  79. }
  80. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  81. {
  82. return 0.01;
  83. }
  84. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  85. {
  86. return 0.01;
  87. }
  88. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  89. {
  90. return 75;
  91. }
  92. /*
  93. #pragma mark - Navigation
  94. // In a storyboard-based application, you will often want to do a little preparation before navigation
  95. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  96. // Get the new view controller using [segue destinationViewController].
  97. // Pass the selected object to the new view controller.
  98. }
  99. */
  100. @end