| | |
| | | #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; |
| | |
| | | } |
| | | @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) |
| | |
| | | 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]; |
| | | } |
| | | |