gpt4 book ai didi

ios - UIScreen 边界小于外部屏幕上的预期

转载 作者:行者123 更新时间:2023-12-01 16:29:04 26 4
gpt4 key购买 nike

我想将内容全屏放置在外部屏幕上(现在是使用 Air Server 的 MacBook Pro),并在平板电脑上放置一个屏幕。

我正在使用 https://github.com/quellish/AirPlayStoryboards 中的示例- 这很棒。但是,我发现两个屏幕都没有显示全屏,因为 UIScreen 的边界太小了——iPad 显示得小一点(信箱),iPad 屏幕只显示左上角屏幕的 1/4(起源)

知道这是为什么吗?编码:

- (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];
}

Log 语句返回如下:
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>>:

有谁知道我可以如何解决这个问题?

最佳答案

您可以像这样获得屏幕尺寸:

    UIScreen *secondaryScreen = [UIScreen screens][1];
UIScreenMode *secondaryScreenMode = [[secondaryScreen availableModes] objectAtIndex: 0];
CGSize sizeSecendaryScreen = secondaryScreenMode.size;
screenWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0, sizeSecendaryScreen.width, sizeSecendaryScreen.height)];

引用: Setting UIScreen's mode / resolution

关于ios - UIScreen 边界小于外部屏幕上的预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33171403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com