iOS 8和ble CBCentralManager无法正常工作

时间:2014-09-20 08:33:37

标签: ios ios8 bluetooth-lowenergy cbcentralmanager

我有一个使用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;
    }

1 个答案:

答案 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

上调用该操作