I am considering adding AirPlay features to one of my ViewControllers. The view controller simply displays the UIWebView. I want to add a button that displays this content on an Apple TV. I know that system-wide mirroring can be done, but it does not fill the entire screen, there are black bars around it. I searched on the Internet, but most of all that I found is a way back with iOS 5 and outdated. Could someone point me towards a textbook or drop library to help? I just need the mirroring of only one view to be full-screen on Apple TV.
So far, this is what I have done, but I believe that it only creates a second window, without putting anything into it.
In AppDelegate, I create a property for it:
@property (nonatomic, retain) UIWindow *secondWindow;
In didFinish, the AppDelegate method runs:
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(handleScreenDidConnectNotification:) name:UIScreenDidConnectNotification object:nil]; [center addObserver:self selector:@selector(handleScreenDidDisconnectNotification:) name:UIScreenDidDisconnectNotification object:nil];
Then in AppDelegate I have:
- (void)handleScreenDidConnectNotification:(NSNotification*)aNotification { UIScreen *newScreen = [aNotification object]; CGRect screenBounds = newScreen.bounds; if (!self.secondWindow) { self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds]; self.secondWindow.screen = newScreen; // Set the initial UI for the window. } } - (void)handleScreenDidDisconnectNotification:(NSNotification*)aNotification { if (self.secondWindow) { // Hide and then delete the window. self.secondWindow.hidden = YES; self.secondWindow = nil; } }
In the viewController, in which I would like to enable the display of WebView on Apple TV, I have:
- (void)checkForExistingScreenAndInitializeIfPresent { if ([[UIScreen screens] count] > 1) {
I got it all from here . However, all that it shows, so I'm not sure how to get content on this screen.