我正在尝试使用不带镜像模式的Airplay在Apple TV上显示图片。但是当镜像关闭时,UIScreen screens方法总是返回一个屏幕(主屏幕)。我希望我的图片显示与照片应用程序相同(没有镜像的Airplay)。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidDisconnect:) name:UIScreenDidDisconnectNotification object:nil];
我用过它们,但它们只有在镜像打开时才起作用。
请帮帮我。非常感谢!我使用的是苹果TV1和iPad 2 (iOS 5.0.1)
发布于 2012-08-20 19:37:32
好吧,这确实有点误导。您应该按照以下步骤进行操作:
UIWindow
并将其附加到第二个屏幕UIWindow
,它将覆盖镜像并显示新内容。代码如下:
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
self.secondWindow = [[UIWindow alloc] initWithFrame:secondScreen.bounds];
[self.secondWindow setScreen:secondScreen];
[self.secondWindow setBackgroundColor:[UIColor greenColor]];
[self.secondWindow makeKeyAndVisible];
https://stackoverflow.com/questions/11391902
复制相似问题