我有一个使用ble连接到设备的iOS应用。 iOS 7正在运行。升级到iOS 8后,CBCentralManager找不到任何外围设备。
case CBCentralManagerStatePoweredOn:
{
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
//NSArray *services = [NSMutableArray new];
NSArray *services = @[[CBUUID UUIDWithString:@"0000FBB0-494C-4F47-4943-544543480000"], [CBUUID UUIDWithString:@"180A"]];
[centralManager scanForPeripheralsWithServices:services options:options];
break;
}
答案 0 :(得分:0)
尝试移动此代码:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
//NSArray *services = [NSMutableArray new];
NSArray *services = @[[CBUUID UUIDWithString:@"0000FBB0-494C-4F47-4943-544543480000"], [CBUUID UUIDWithString:@"180A"]];
[centralManager scanForPeripheralsWithServices:services options:options];
进入Iba操作,然后在CBCentralManagerStatePoweredOn
上调用该操作