I'm trying to display a picture on Apple TV with Airplay without mirroring mode. But [UIScreen screens] method always return 1 screen (main screen) when mirroring is OFF. I want my picture display same as Photo application (Airplay without mirroring).
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidDisconnect:) name:UIScreenDidDisconnectNotification object:nil];
I used them, but they only work when Mirroring is ON.
Please help me. Thanks so much! I'm using Apple TV1 and iPad 2 (iOS 5.0.1)
Well, it's a bit misleading, indeed. You should proceed as follows:
UIWindow
and attach it to the second screenUIWindow
, it overrides mirroring and shows new content.Here's the code:
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];