From 64b0493e4bd40c46e341fd5de9f1862998c431b0 Mon Sep 17 00:00:00 2001 From: lijunda <475576921@qq.com> Date: Thu, 16 Aug 2018 16:35:30 +0800 Subject: [PATCH] 无修改,测试混淆代码 --- pregnancy_guard/BaseProject/Controller/Home/SearchDevicePage.m | 114 +++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 78 insertions(+), 36 deletions(-) diff --git a/pregnancy_guard/BaseProject/Controller/Home/SearchDevicePage.m b/pregnancy_guard/BaseProject/Controller/Home/SearchDevicePage.m index c99daa2..381510b 100644 --- a/pregnancy_guard/BaseProject/Controller/Home/SearchDevicePage.m +++ b/pregnancy_guard/BaseProject/Controller/Home/SearchDevicePage.m @@ -15,8 +15,9 @@ #import "UIView+Toast.h" #import "UIImage+animatedGIF.h" #import "SearchTipsCell.h" +#import <CoreBluetooth/CoreBluetooth.h> -@interface SearchDevicePage ()<UITableViewDelegate,UITableViewDataSource> +@interface SearchDevicePage ()<UITableViewDelegate,UITableViewDataSource,CBCentralManagerDelegate> { BOOL isBluetoothON; UIButton* ic_search_btn; @@ -29,12 +30,48 @@ } @property (nonatomic, strong) UITableView * tableView; @property (nonatomic, assign) int currentStatus; // 0 ��������� 1 ��������� 2 ������������ - +@property (nonatomic, strong) CBCentralManager * centralManager; @end @implementation SearchDevicePage + +//-(CBCentralManager *)centralManager +//{ +// if (_centralManager == nil) { +// _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil]; +// } +// return _centralManager; +//} + +-(void)centralManagerDidUpdateState:(CBCentralManager *)central +{ + switch (central.state) { + case CBCentralManagerStatePoweredOff: + { + //[mainView makeToast:@"���������������������������������������������"]; + [Global alertMessageEx:@"���������������������������������������������������" title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + break; + case CBCentralManagerStatePoweredOn: + NSLog(@"������������������"); + break; + case CBCentralManagerStateResetting: + break; + case CBCentralManagerStateUnauthorized: + break; + case CBCentralManagerStateUnknown: + break; + case CBCentralManagerStateUnsupported: + NSLog(@"���������������������������"); + [Global alertMessageEx:@"���������������������������������������" title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + break; + default: + break; + } +} + - (UITableView *)tableView { if (!_tableView) @@ -61,7 +98,7 @@ { [super viewDidAppear:animated]; [[CBMoralManager sharedManager] disconnectPeripheral:[[CBMoralManager sharedManager] myPeripheral]]; - + } @@ -114,10 +151,12 @@ ic_top_bkH = 325; ic_search_doneH = 230; + CGFloat btnSearchH = 55; if ( IsiPhone4 || IsiPhone5 ) { ic_top_bkH = 260; ic_search_doneH = 180; + btnSearchH = 40; } UIImageView * ic_top_bk = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ic_top_bkH)]; @@ -134,7 +173,7 @@ ic_searching.hidden = YES; ic_search_btn = [UIButton buttonWithType:UIButtonTypeCustom]; - ic_search_btn.frame = CGRectMake((SCREEN_WIDTH-128)/2, ic_search_doneH+55, 128, 32); + ic_search_btn.frame = CGRectMake((SCREEN_WIDTH-128)/2, ic_search_doneH+btnSearchH, 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; @@ -144,6 +183,8 @@ self.tableView.hidden = NO; // Do any additional setup after loading the view. + + self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil]; [[CBMoralManager sharedManager] setCbDiscoveryDelegate:self]; } @@ -204,7 +245,7 @@ _SetTitleLabel.text = @"������������������"; return cell; - + } else { @@ -292,10 +333,10 @@ //[cell setDiscoveredPeripheralDataFromPeripheral:newPeriPheral]; - return cell; + return cell; } } - + return nil; } @@ -367,28 +408,28 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ - - if (_currentStatus == 2) - { - NSInteger index = [indexPath row]; - if (isBluetoothON) - { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - [self connectPeripheral: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]; - } - + if (_currentStatus == 2) + { + NSInteger index = [indexPath row]; + if (isBluetoothON) + { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + [self connectPeripheral: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]; + } + + } @@ -449,7 +490,7 @@ [UserDefault setObject:bleUUID forKey:@"bleUUID"]; [UserDefault setObject:bleName forKey:@"bleName"]; - [UserDefault synchronize];//������synchronize���������������������������������,���������������NSUserDefaults������������������������������������ + [UserDefault synchronize];//������synchronize���������������������������������,���������������NSUserDefaults������������������������������������ //CBPeripheralExt *selBLE = [UserDefault objectForKey:@"Peripheral"];//������������������Peripheral [self backAticon]; } @@ -508,13 +549,14 @@ } /* -#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. -} -*/ + #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 + -- Gitblit v1.8.0