在iOS7 +上以编程方式打开蓝牙的任何方法
问题描述:
我听说iOS7在CBCentralManager中引入了此功能,但找不到方法.有可能吗还有另外一种使用GKPeerPickerController的widthout方法吗?
I hear that iOS7 introduced this functionality with CBCentralManager but can't find how. Is possible? There is another way widthout use GKPeerPickerController?
答
否,如果用户关闭了蓝牙,则您只能显示警报或消息,要求他们将其打开.
No, if the user has turned off Bluetooth all you can do is display an alert or message asking them to turn it on.
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if (central.state == CBCentralManagerStatePoweredOff) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Please turn on Bluetooth in Settings" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}