gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:51:56 25 4
gpt4 key购买 nike

无论您是否检查镜像,是否还有人在使用 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 5.0 开始,您只会在以下情况下收到通知:

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

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

关于ios - 屏幕连接/断开通知是否适用于 iOS 5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7908896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com