ios - 如果蓝牙关闭 iOS,禁用警告对话框

标签 ios objective-c ios6 bluetooth ios7

我的 iOS 应用程序使用蓝牙连接到配件。如果未启用蓝牙,则会出现一个弹出窗口要求我激活。

Bluetooth Popup

我注意到每次运行该应用程序时都会出现弹出窗口。

我的问题是是否可以显示弹出窗口一次,即仅在第一次启动后显示 ( fitbit app do that 。我还想知道是否可以更改弹出窗口的语言。

我的应用程序适用于 iOS7 和 iOS6

如果我们不能更改语言,有没有办法禁用此弹出窗口,那么我将使用本地化系统开发自己的 View (弹出窗口)?

非常感谢!

最佳答案

我从一位苹果开发者那里得到了以下回复: 在 iOS7 中,CBCentralManagerOptionShowPowerAlertKey 选项可让您禁用此警报。

如果你有一个CBCentralManager,那么当你初始化它时,你可以使用方法-[CBCentralManager initWithDelegate:queue:options]

示例:

在我的 .h 文件中,我有一个 CBCentralManager * manager

在我的 .m 文件中:

NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey: @NO};
    
_manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
    
[_manager scanForPeripheralsWithServices:nil options:options];

使用此代码,警告不再出现。希望对您有所帮助!

关于ios - 如果蓝牙关闭 iOS,禁用警告对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19296642/

相关文章:

ios - 静态属性观察者

iphone - 在 iPhone 应用程序中嵌入 youtube 视频

ios - 为什么调用 XMLParser(contentsOfURL : rssURL) is giving error: 'Argument passed to call that takes no arguments' ?

objective-c - 将 QLPreviewController 添加为 subview 不会加载 PDF

iphone - 如何在iPhone APP中获取状态栏图像

iphone - 如何使用自定义 NSDataDetector 来检测某些正则表达式模式?

ios - 使用 UIImagePickerController 使 UIView 显示相机 View

objective-c - dismissModalViewControllerAnimated 没有可见界面 :completion

ios - 从网络下载图像时如何找到 "UIImagePickerControllerOriginalImage"和 "UIImagePickerControllerReferenceURL"

ios6 - 在设备上切换 FB 帐户时,Facebook 授权在 iOS6 上失败