屏幕连接/断开通知是否适用于 iOS 5?

发布于 2024-12-12 00:22:02 字数 1396 浏览 0 评论 0原文

无论您是否检查镜像,是否有人仍然会在 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 {
         ...
    }

Is anyone still getting, with iOS 5, screen connect/disconnect notifications, regardless of whether you check mirroring or not? I don't seem to be getting any notifications, unless I plug a video-out cable to my device, instead of using AirPlay.

I have an AirPlay button in my app, provided by MPVolumeView. I can tap it and select an Apple TV. The AirPlay button turns blue. I get no notification.

I can go to the "Now Playing" screen (double-click and page to one end), and select an Apple TV. I get confirmation as the AirPlay icon turns blue. My app gets no confirmation (even after returning to it).

I can go to the "Now Playing" screen (double-click and page to one end), and select an Apple TV AND select mirroring. I get confirmation as the AirPlay icon turns blue. My app gets no confirmation (even after returning to it).

I quit my app, I leave mirroring on. I restart my app. I have code that checks for the number of screens. I only see one.

I am hoping I am doing something wrong, but I want to check and make sure others out there are getting notifications when using AirPlay. I recall having tested my AirPlay compatibility during the 5.0 betas, and not having had these issues.

(Apple's ExternalDisplay sample is behaving the same way.)

Code I use for notification registration:

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

Code the notifications should call:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-12-19 00:22:02

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

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

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

Turns out that as of iOS 5.0 you only get notification, in the following cases:

  • iPad 2 or iPhone 4s
    and
  • you have to turn mirroring on in the "Now Playing" screen of the device (tap home button twice, go to the leftmost page, tap on the AirPlay icon, select an AppleTV and turn on mirroring). This seems odd, but that's the way it works. Just selecting an AirPlay AppleTV without mirroring let's you use the AppleTV for content that is displayed within AVPlayer's framework.

With an HDMI cable, more devices can utilize a second screen using UIScreen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文