0

I'm Working with Core Bluetooth Framework. In this app I had to connect multiple Bluetooth device with the iPhone and when Bluetooth device goes out of range it shows an alert.

Instead of this alert I want to show UIViewController.All the coding of Alert is handled on NSObject Classes.

Here is the Screen which I want to show instead of AlertView

enter image description here

4

3 回答 3

1

另一种方法:
- 在您的通信类上创建一个委托。
- 将您的 ViewController 设置为其委托。
- 当外围设备断开连接时告诉代理,它将显示您的自定义屏幕屏幕...

于 2013-05-23T10:53:25.140 回答
1

如果我正确理解了您的问题,您需要在 NSObject 子类的对象中引用活动的 UIViewController 。因此,当实例化当前处理 AlertView 的 NSObject 时,向它发送一个对活动 UIViewController 的引用,如果您从活动 UIViewController 实例化它,则类似这样:

NSObjectSubclass *alertViewHandler = [[NSObjectSubclass alloc] init];
[alertViewHandler setActiveViewController:self];

然后稍后在您的 alertViewHandler 中,您可以执行以下操作而不是显示警报:

[activeViewController presentViewController:viewControllerToPresent animated:YES completion:nil];

您的问题有更多不同的解决方案,但由于信息有限,我只能猜测哪一个最适合您。

于 2013-05-23T05:52:56.840 回答
0

同样,每个问题都有解决方案,考虑到这一点,我尝试并得到了解决方案

从 NSObject 显示 UiViewController - 我使用来自 App Delegate Class 的引用,因为 AppDelegate 有自己的 UIViewController,并且我将风覆盖与我的 UIViewController 一起使用。

在上述情况下,我不能使用 pushViewController 或 PresentViewController,因为所有功能都在 ViewController 中工作,因为我必须从 NSObject 调用视图,所以我认为这是解决此类问题的最佳且简单的方法。

于 2013-05-24T05:13:33.457 回答