| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- //
- // DeveceDetail_VC.m
- // Haishenghai-master
- //
- // Created by GG on 2019/1/4.
- // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
- //
- #import "DeveceDetail_VC.h"
- #import "TableheaderView.h"
- @interface DeveceDetail_VC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,copy)NSString *state;
- @property (nonatomic,strong)UITableView *myTable;
- @property (nonatomic,strong)UIView *headerView;
- @property (nonatomic,strong)NSMutableArray *dataArray;
- @end
- /**自定义时间轴单元格 */
- @implementation DeveceDetail_VC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
- self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
- UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
- backBtn.frame = CGRectMake(0, 0, 44, 44);
- [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
-
- self.navigationItem.title =@"设备详情";
- // if (@available (iOS 11.0,*)) {
- // self.myTable.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- // }else{
- // self.automaticallyAdjustsScrollViewInsets = NO;
- // }
- [self setupUI];
- [DataSourceManager getDeveceDataChangedWithUrluploadDeveceID:_deveceID Page:1 Pagesize:100 completionBlock:^(NSMutableArray *array) {
- _dataArray =array;
- [_myTable reloadData];
- }];
- }
- -(void)backClick{
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)setupUI{
- [self.view addSubview:_myTable];
- //设置表头 //需要自定义headerView+model数据型的
- TableheaderView *view = [[TableheaderView alloc]init];
- view.frame = CGRectMake(0, 0, WIDTH, 110);
- self.myTable.tableHeaderView = view;
- self.myTable.showsVerticalScrollIndicator = NO;
- // view.backgroundColor = [UIColor grayColor];
- // [_headerView addSubview:view];
- view.nameLabel.text = _deviceName;
- if ([_state isEqualToString:@"1"]) {
- view.stateLabel.text = @"火警";
- view.stateLabel.textColor = [UIColor redColor];
- }
- view.detailLabel.text = @"电信运营商";
- view.numberLabel.text = _deveceID;
- view.locationLabel.text = _location;
- view.d_locationLabel.text = _d_location;
- }
- #pragma mark--lazy--------
- -(UITableView *)myTable{
- if (!_myTable) {
- UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
- tableView.delegate = self;
- tableView.dataSource = self;
- [self.view addSubview:tableView];
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _myTable = tableView;
- }
- return _myTable;
- }
- #pragma mark----tableviewDelegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _dataArray.count;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 100;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellID = @"cell";
- DetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];;
- if (!cell) {
- cell = [[DetailTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
-
- }
- detatilDeviceModel *detail = [self.dataArray objectAtIndex:indexPath.row];
- cell.timeLabel.text=detail.inputtime;
- if ([detail.devicestatus isEqualToNumber:@(8)]||[detail.fireAlarm isEqualToNumber:@(1)]) {
- cell.stateLabel.text =@"状态:火警";
- cell.stateLabel.textColor = [UIColor redColor];
- cell.pointImg.image =[UIImage imageNamed:@"hsh_home_alert_point"];
- }else{
- cell.stateLabel.text =@"状态:正常";
- cell.stateLabel.textColor = [UIColor blueColor];
- cell.pointImg.image =[UIImage imageNamed:@"hsh_home_details_normal"];
- }
- cell.voltageLabel.text = [NSString stringWithFormat:@"当前电池电压:%@",detail.batteryVoltage];
- cell.signalLabel.text =[NSString stringWithFormat:@"信号强度:%@",detail.signalStrength];
- cell.tempLabel.text = [NSString stringWithFormat:@"CPU温度:%@",detail.mcuTemp];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- return cell;
- }
- //编辑单元格使用的方法
- -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
- return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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
|