iPhone – 使用UIScreen驱动VGA显示 – 似乎没有显示UIWindow?

嗨,您好,

我正在尝试使用UIScreen在iPad上使用VGA加密狗来驱动单独的屏幕.

这是我在根视图控制器的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];

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...