gpt4 book ai didi

iphone - 使用 UIScreen 驱动 VGA 显示器 - 似乎没有显示 UIWindow?

转载 作者:行者123 更新时间:2023-12-03 18:41:53 25 4
gpt4 key购买 nike

你好,

我正在尝试使用 UIScreen 来通过 iPad 上的 VGA 适配器驱动单独的屏幕。

这是我在 Root View Controller 的 viewDidLoad 中得到的内容:

//Code to detect if an external display is connected to the iPad.
NSLog(@"Number of screens: %d", [[UIScreen screens]count]);

//Now, if there's an external screen, we need to find its modes, itereate through them and find the highest one. Once we have that mode, break out, and set the UIWindow.

if([[UIScreen screens]count] > 1) //if there are more than 1 screens connected to the device
{
CGSize max;
UIScreenMode *maxScreenMode;
for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
{
UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
if(current.size.width > max.width);
{
max = current.size;
maxScreenMode = current;
}
}
//Now we have the highest mode. Turn the external display to use that mode.
UIScreen *external = [[UIScreen screens] objectAtIndex:1];
external.currentMode = maxScreenMode;
//Boom! Now the external display is set to the proper mode. We need to now set the screen of a new UIWindow to the external screen
external_disp = [externalDisplay alloc];
external_disp.drawImage = drawViewController.drawImage;
UIWindow *newwindow = [UIWindow alloc];
[newwindow addSubview:external_disp.view];
newwindow.screen = external;
}

最佳答案

您需要初始化窗口...

 UIWindow *newwindow = [[UIWindow alloc] init];

关于iphone - 使用 UIScreen 驱动 VGA 显示器 - 似乎没有显示 UIWindow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2660473/

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