// // SearchDevicePage.m // pregnancy_guard // // Created by WindShan on 2017/7/11. // Copyright © 2017年 WindShan. All rights reserved. // #import "SearchDevicePage.h" #import "GloriaLabel.h" #import "SearchDeviceCell.h" @interface SearchDevicePage () @property (nonatomic, strong) UITableView * tableView; @property (nonatomic, assign) int currentStatus; // 0 初始化 1 检索中 2 检索完成 @property (nonatomic, strong) NSMutableArray * modelArray; @end @implementation SearchDevicePage - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] init]; _tableView.delegate = self; _tableView.dataSource = self; //_tableView.separatorColor = [UIColor clearColor]; [self.view addSubview:_tableView]; [_tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(UIEdgeInsetsMake(325 , 0, 0, 0)); }]; _tableView.tableFooterView = [UIView new]; } return _tableView; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"设备匹配"; [self setNavigationLeft:@"ic_back_arraw.png" sel:@selector(backAticon)]; [self setNavigationRight:@"icon_story.png" sel:@selector(storyAticon)]; self.currentStatus = 0; UIImageView * ic_top_bk = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 325)]; ic_top_bk.image = [UIImage imageNamed:@"ic_top_bk"]; [self.view addSubview:ic_top_bk]; UIImageView * ic_search_done = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-230)/2, 20, 230, 230)]; ic_search_done.image = [UIImage imageNamed:@"ic_search_done"]; [self.view addSubview:ic_search_done]; UIButton* ic_search_btn = [UIButton buttonWithType:UIButtonTypeCustom]; ic_search_btn.frame = CGRectMake((SCREEN_WIDTH-128)/2, 20+230+20, 128, 32); [ic_search_btn setBackgroundImage:[UIImage imageNamed:@"ic_search_start_btn" ] forState:UIControlStateNormal]; ic_search_btn.titleLabel.font = [UIFont systemFontOfSize: 18.0]; ic_search_btn.layer.masksToBounds=YES; ic_search_btn.layer.cornerRadius=8.0f; [ic_search_btn addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:ic_search_btn]; self.tableView.hidden = NO; // Do any additional setup after loading the view. } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (_currentStatus == 2) { return 2; } else return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (_currentStatus == 2) { return self.modelArray.count; } else return 5; } //此处上面和下面 是设置 footerview - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (_currentStatus != 2) { static NSString *CellIdentifier = @"searchDeviceCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } NSUInteger index = [indexPath row]; switch (index) { case 0: { GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10, 6,SCREEN_WIDTH/2, 30)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"操作设置步骤"; [cell.contentView addSubview:_TitleLabel]; } break; case 1: { UIImageView * icon_one = [[UIImageView alloc] initWithFrame:CGRectMake(10, 11, 22, 22)]; icon_one.image = [UIImage imageNamed:@"icon_one"]; [cell.contentView addSubview:icon_one]; GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+22+10, 15,SCREEN_WIDTH-(10+22+10), 22)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"打开孕哨设备电源开关"; [cell.contentView addSubview:_TitleLabel]; } break; case 2: { UIImageView * icon_two = [[UIImageView alloc] initWithFrame:CGRectMake(10, 11, 22, 22)]; icon_two.image = [UIImage imageNamed:@"icon-two"]; [cell.contentView addSubview:icon_two]; GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+22+10, 15,SCREEN_WIDTH-(10+22+10), 22)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"打开手机蓝牙"; [cell.contentView addSubview:_TitleLabel]; } break; case 3: { UIImageView * icon_three = [[UIImageView alloc] initWithFrame:CGRectMake(10, 11, 22, 22)]; icon_three.image = [UIImage imageNamed:@"icon-three"]; [cell.contentView addSubview:icon_three]; GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+22+10, 15,SCREEN_WIDTH-(10+22+10), 22)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"点击APP按钮[开始搜索设备]"; [cell.contentView addSubview:_TitleLabel]; } break; case 4: { UIImageView * icon_four = [[UIImageView alloc] initWithFrame:CGRectMake(10, 11, 22, 22)]; icon_four.image = [UIImage imageNamed:@"icon-four"]; [cell.contentView addSubview:icon_four]; GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+22+10, 15,SCREEN_WIDTH-(10+22+10), 22)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"搜索完毕,点击对应蓝牙列表,自动匹配"; [cell.contentView addSubview:_TitleLabel]; } break; } return cell; } else { static NSString *CellIdentifier = @"searchDeviceCell"; SearchDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[SearchDeviceCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } NSUInteger section = [indexPath section]; if(section==0) { GloriaLabel* _TitleLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(20, 15,SCREEN_WIDTH/2, 20)]; _TitleLabel.font = [UIFont systemFontOfSize:14]; _TitleLabel.textAlignment = UITextAlignmentLeft; _TitleLabel.textColor = kUIColorFromRGB(0x595959); _TitleLabel.text = @"蓝牙列表"; [cell.contentView addSubview:_TitleLabel]; } else if(section==1) { DeviceSpareModel* model = [self.modelArray objectAtIndex:indexPath.row]; [cell setItemView:model]; } return cell; } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if (_currentStatus == 2) { NSInteger index = [indexPath row]; DeviceSpareModel* model = [self.modelArray objectAtIndex:index]; // 跳转酒店备用界面 //HotelSelPage* page = [[HotelSelPage alloc] initIsFirstPage:NO]; //page.bSelRoom = 2; // 跳转界面 //BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:page]; //[self presentViewController:baseNav animated:YES completion:nil]; //[self showActionForPhoto]; } } -(void)searchAction { } -(void)storyAticon { } -(void)backAticon { //[self.navigationController popToViewController:self animated:YES]; [self dismissViewControllerAnimated:YES completion:nil]; } - (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