[英]How can I open bluetooth setting on button press in ios9?
I want to open bluetooth setting page on click of one button. 我想单击一个按钮打开蓝牙设置页面。 Currently, it is opening General page.
目前,它正在打开“常规”页面。
I am doing following for that: 为此,我正在做以下事情:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Bluetooth"]];
Now you can open only current app settings, sorry ..... https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html 现在,您只能打开当前的应用程序设置,对不起..... https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html
You can on/off bluetooth by 您可以通过以下方式打开/关闭蓝牙
BluetoothManager *manager = [BluetoothManager sharedInstance];
[manager setEnabled:![manager enabled]];
Use this URL Scheme: 使用以下URL方案:
prefs:root=General&path=Bluetooth
prefs:root = General&path =蓝牙
Below is the code: 下面是代码:
NSURL*url=[[NSURL alloc] initWithString:@"prefs:root=General&path=Bluetooth"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
This will work for opening General screen in Settings for bluetooth 这适用于在“蓝牙设置”中打开“常规”屏幕
PS: Don't forget to add URL Types
in targets info.plist file as shown below: PS:不要忘了在目标info.plist文件中添加
URL Types
,如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.