Reputation: 1
I do not get the Second Display to Show any other then Mirroring my Device Screen. I allways see only the mirrored device screen on my tv. This is My Code i hope someone can help me.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(configureScreens) name:UIScreenDidConnectNotification object:nil];
[center addObserver:self selector:@selector(configureScreens) name:UIScreenDidDisconnectNotification object:nil];
[self configureScreens];
return YES;
}
-(void)configureScreens
{
NSUInteger screenCount = [[UIScreen screens] count];
NSLog(@"%u",screenCount);
if (screenCount == 1) {
//single windows
}else if(screenCount == 2) {
UIScreen *appleTvScreen = [[UIScreen screens] objectAtIndex:1];
UIWindow *tvWindow = [[UIWindow alloc] initWithFrame:appleTvScreen.bounds];
tvWindow.screen = appleTvScreen;
tvWindow.backgroundColor = [UIColor redColor];
tvWindow.rootViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"tv"];
tvWindow.hidden = NO;
}
}
Upvotes: 0
Views: 829
Reputation: 698
I can suggest you try the sample source code TVOut on GITHub - https://github.com/JohnGoodstadt/TVOut.
It uses similar code to yours but packaged in a class which you can copy over and call from your own code.
It should solve your display problem.
Upvotes: 1