0
我沒有看到第二顯示器顯示任何其他信息,然後鏡像我的設備屏幕。 我總是隻能看到我電視上的鏡像設備屏幕。 這是我的代碼,我希望有人能幫助我。iOS第二顯示器
- (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;
}
}
您將如何檢測設備名稱。如果有多個Airplay設備,如何選擇要選擇的電視機? – andyPaul