// // YXDeviceInfoViewController.m // Temperature // // Created by TC on 2025/2/22. // #import "YXDeviceInfoViewController.h" #import "YXDeviceInfoCell.h" @interface YXDeviceInfoViewController () @property (weak, nonatomic) UITableView *tableView; @property (copy, nonatomic) NSArray *dataArray; @end @implementation YXDeviceInfoViewController - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"设备信息"; self.view.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"]; self.dataArray = @[ @"版本号",@"运行时长",@"运行记录",@"耗材提醒" ]; [self createTableView]; } -(void)createTableView { UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(15, 0, self.view.frame.size.width - 30, self.view.frame.size.height - kNavHeight - kTabbarHeight) style:UITableViewStyleGrouped]; tableView.delegate = self; tableView.dataSource = self; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [tableView registerNib:[UINib nibWithNibName:@"YXDeviceInfoCell" bundle:nil] forCellReuseIdentifier:@"myDeviceInfoCellID"]; tableView.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"]; [self.view addSubview:tableView]; self.tableView = tableView; tableView.layer.cornerRadius = 8; [self createTableHeaderView]; } -(void)createTableHeaderView { UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 10)]; headerView.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"]; self.tableView.tableHeaderView = headerView; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { YXDeviceInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myDeviceInfoCellID" forIndexPath:indexPath]; cell.selectionStyle = UITableViewCellSelectionStyleNone; NSString *title = self.dataArray[indexPath.row]; cell.titleLabel.text = title; if (indexPath.row == 0) { cell.detailLabel.hidden = NO; cell.detailLabel.text = @"2024-02-23 v2.3"; } else if (indexPath.row == 1) { cell.detailLabel.hidden = NO; cell.detailLabel.text = @"2小时"; }else{ cell.detailLabel.hidden = YES; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc]init]; return headerView; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footerView = [[UIView alloc]init]; return footerView; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0.01; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.01; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 75; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end