我希望在屏幕上以全屏方式在屏幕上放置内容(现在是使用Air Server的MacBook Pro)。UIScreen在外部屏幕上的边界比预期的要小
我使用https://github.com/quellish/AirPlayStoryboards的例子 - 这很好。但是,我发现两个屏幕都不显示全屏,因为UIScreen的界限回到了太小 - iPad显示的是一个较小的(letterboxed),而iPad屏幕只显示左上角的四分之一屏幕(原产地)
任何想法,为什么这是?代码:
- (void) application:(UIApplication *)__unused application didConnectScreen:(UIScreen *) screen
{
UIStoryboard *storyboard = nil;
UIWindow *screenWindow = nil;
UIViewController *tvViewController = nil;
// Set up external screen
UIScreen *secondaryScreen = [UIScreen screens][1];
UIScreen *primaryScreen = [UIScreen screens][0];
NSLog(@"Screen 1 (iPad): %@", primaryScreen); //print the bounds of the iPad
NSLog(@"Screen 2 (MacBook): %@:", secondaryScreen); //print the bounds and size of the MacBook
UIScreenMode *screenMode = [[secondaryScreen availableModes] lastObject];
CGRect bounds = secondaryScreen.bounds;
// Create new outputWindow
screenWindow = [[UIWindow alloc] initWithFrame:bounds];
screenWindow.screen = secondaryScreen;
screenWindow.screen.currentMode = screenMode;
[screenWindow makeKeyAndVisible];
[screenWindow setScreen:screen];
storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle bundleForClass:[self class]]];
tvViewController = [storyboard instantiateViewControllerWithIdentifier:@"TVViewController"];
[screenWindow setClipsToBounds:YES];
[screenWindow setRootViewController:tvViewController];
[screenWindow setHidden:NO];
// // If you do not retain the window, it will go away and you will see nothing.
[[self windows] addObject:screenWindow];
}
日志语句返回如下:
Screen 1 (iPad): <UIScreen: 0x1567def0; bounds = {{0, 0}, {480, 320}}; mode = <UIScreenMode: 0x1567dd60; size = 1024.000000 x 768.000000>>
Screen 2 (MacBook): <UIScreen: 0x15680280; bounds = {{0, 0}, {640, 400}}; mode = <UIScreenMode: 0x156804a0; size = 1280.000000 x 800.000000>>:
有谁知道我怎么可能会解决这个问题?
嘿,托尼,你能解释一下如何解决这个问题吗? – Cornelius