ios - 在 iOS 中更改 UIViewController 时保持蓝牙连接

标签 ios uiviewcontroller core-location cbperipheral

我将外围委托(delegate)的方法放在我的 2 UIViewController 中,但是当我进入第二个时,我失去了连接,它又重新连接了。 我想要的很简单,就是保持与相同的 CBPeripheralManager 和 CBMUtableCharacteristic 的连接。有什么解决办法吗?

谢谢

最佳答案

例如对于简单的app,可以在appDelegate中创建CBPeripheralManager

但正确的方法是为整个应用程序(单例)创建专用对象,它将由 CBPeripheralManager 委托(delegate)并向所有界面 Controller 提供数据

关于ios - 在 iOS 中更改 UIViewController 时保持蓝牙连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22507418/

相关文章:

ios - 在具有动态高度的 IB uitableviewcell 中使用带有 XIB 的自定义 View

ios - NSNumber 类型的托管属性?没有初始化为 nil

ios - 安全地存储数据,应用程序如何做到这一点?

objective-c - 重用 View Controller

ios - 在 UIViewController 上设置方向

iphone - 在后台线程上接收 CLLocation 更新

iphone - CLGeocoder 地理编码极其不准确

ios - 有没有比 dispatch_once 更短的替代方案?

ios - 如何在 iOS 中单击注销按钮时移动到根 ViewController?

iOS 后台模式 : After running location updates in the background, 应用程序永远不会终止