6

やあ、

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;
 }
4

6 に答える 6

8

ウィンドウを初期化する必要があります...

 UIWindow *newwindow = [[UIWindow alloc] init];
于 2010-04-19T13:57:57.057 に答える
2

あなたの問題はexternalDisplayだと思います。コードの外部でViewControllerを作成し(おそらく、単に新しいファイルViewControllerを追加し、.xibに何かを入れます)、外部ディスプレイに呼び出す前に、ViewControllerが機能していることを確認してみてください。これが私の提案された変更を含むコードです-[mainViewControllerview]は外部で作成したviewcontrollerです。

//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, iterate
//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

 UIWindow *newwindow = [UIWindow alloc];

 [newwindow addSubview:[mainViewController view]];
 newwindow.screen = external;

 [newwindow makeKeyAndVisible];
 [newwindow setHidden:NO];
}
于 2010-07-09T20:58:11.953 に答える
2

[newwindow makeKeyAndVisible];?

于 2010-04-17T23:36:30.480 に答える
1

サンプル .xcodeproj を github にアップロードしました。

主にこのページを参考にしました。

どうもありがとう。:)

http://github.com/igaiga/iPadDisplayOutSample

于 2010-07-23T02:24:14.090 に答える
0

このページと igaiga による github リンクで提供されるコードは、通常は iPad (または他のデバイス) に表示されるビューを単に「移動」(クローンではなく) するためのものであることに注意する必要があります。

ビューのクローン (別名ミラー) とそのコンテンツの更新が必要な場合は、次のリンクが適しています: http://www.touchcentric.com/blog/archives/123

これが、ビデオ出力機能を既存のアプリに統合し始めたばかりのユーザー向けに、両方のコード セットのユース ケースを明確にするのに役立つことを願っています。

于 2010-11-02T13:28:51.957 に答える