屏幕连接/断开通知是否适用于 iOS 5?
无论您是否检查镜像,是否有人仍然会在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,从 iOS 5.0 开始,您只会在以下情况下收到通知:
并且
借助 HDMI 电缆,更多设备可以使用 UIScreen 使用第二个屏幕。
Turns out that as of iOS 5.0 you only get notification, in the following cases:
and
With an HDMI cable, more devices can utilize a second screen using UIScreen.