UIScreenMirroredScreen 属性始终返回 nil
如果设备(原始 iPad)不支持镜像,我想在外部连接的显示器上呈现独特的内容,但如果是 iPad 2,我想使用屏幕镜像。现在,当我尝试按如下方式编写代码时:
if ([UIScreen instancesRespondToSelector:@selector(mirroredScreen)] && [[UIScreen mainScreen] mirroredScreen] == nil) {
// Mirroring not supported. Present unique content on external display
}
[[UIScreen mainScreen]mirroredScreen]
始终返回 nil
。
我做错了什么吗?
I want to present unique content on the external connected display if mirroring is not supported by the device (original iPad) but want to use screen mirroring if it's iPad 2. Now when I try to code this as follows:
if ([UIScreen instancesRespondToSelector:@selector(mirroredScreen)] && [[UIScreen mainScreen] mirroredScreen] == nil) {
// Mirroring not supported. Present unique content on external display
}
[[UIScreen mainScreen] mirroredScreen]
always returns nil
.
Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我了解文档,如果您访问实际上是镜像屏幕的辅助屏幕上的属性,
mirroredScreen
将引用主屏幕。如:[[UIScreen mainScreen]mirroredScreen]
将始终返回nil
,因为 mainScreen 不会镜像自身。As I understand the documentation,
mirroredScreen
will reference the main screen if you access the property on a secondary screen that actually is the mirrored screen. As in:[[UIScreen mainScreen] mirroredScreen]
would then always returnnil
because the mainScreen does not mirror itself.Apple 在此处提供了有关检测屏幕是否镜像的方法的建议:http://developer.apple.com/library/ios/#qa/qa1738/_index.html
Apple have a recommendation about the way to detect if the screen is mirrored or not here : http://developer.apple.com/library/ios/#qa/qa1738/_index.html