【问题标题】:Are screen connect/disconnect notifications working with iOS 5?屏幕连接/断开通知是否适用于 iOS 5?
【发布时间】:2011-12-16 01:42:57
【问题描述】:

是否还有人在使用 iOS 5 时收到屏幕连接/断开连接通知,无论您是否检查镜像?我似乎没有收到任何通知,除非我将视频输出电缆插入我的设备,而不是使用 AirPlay。

我的应用中有一个 AirPlay 按钮,由 MPVolumeView 提供。我可以点击它并选择 Apple TV。 AirPlay 按钮变为蓝色。我没有收到任何通知。

我可以转到“正在播放”屏幕(双击并翻页),然后选择 Apple TV。当 AirPlay 图标变为蓝色时,我得到确认。我的应用没有得到确认(即使在返回它之后)。

我可以转到“正在播放”屏幕(双击并翻页),然后选择 Apple TV 并选择镜像。当 AirPlay 图标变为蓝色时,我得到确认。我的应用没有得到确认(即使在返回它之后)。

我退出了我的应用程序,我保留了镜像。我重新启动我的应用程序。我有检查屏幕数量的代码。我只看到一个。

我希望我做错了什么,但我想检查并确保其他人在使用 AirPlay 时收到通知。我记得在 5.0 测试版期间测试了我的 AirPlay 兼容性,但没有遇到这些问题。

(Apple 的 ExternalDisplay 示例的行为方式相同。)

我用于通知注册的代码:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(screenDidConnect:)
                                             name:UIScreenDidConnectNotification
                                         object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(screenDidConnect:)
                                             name:UIScreenDidDisconnectNotification 
                                           object:nil];

通知应该调用的代码:

- (void) screenDidConnect:(NSNotification *)notification {
    if ([[UIScreen screens] count] > 1) 
        [self myScreenInit:[notification object]];
    else {
         ...
    }

【问题讨论】:

  • 我遇到了同样的问题

标签: ios airplay uiscreen


【解决方案1】:

事实证明,从 iOS 5.0 开始,您只会在以下情况下收到通知:

  • iPad 2 或 iPhone 4s 和
  • 您必须在设备的“正在播放”屏幕中打开镜像(点击主页按钮两次,转到最左侧页面,点击 AirPlay 图标,选择 AppleTV 并打开镜像)。这看起来很奇怪,但这就是它的工作方式。只需选择不带镜像的 AirPlay AppleTV,您就可以将 AppleTV 用于显示在 AVPlayer 框架内的内容。

借助 HDMI 线缆,更多设备可以通过 UIScreen 使用第二个屏幕。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多