将ipad连接到外部显示器 [英] Connecting ipad to external monitor

查看:138
本文介绍了将ipad连接到外部显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下方法将我的ipad应用程序连接到外部屏幕(不是现在检查正确的分辨率 - 只是想要它并运行)。

I am trying to connect my ipad app to an external screen using the following (not checking the correct resolution for now - just want it up and running).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
     [window addSubview:[navigationController view]];
     if ([[UIScreen screens] count] > 1) {
          window.screen = [[UIScreen screens] objectAtIndex:1];
     }
     [window makeKeyAndVisible];
     return YES;
}

这是否应该将所有内容重定向到外部监视器?如何使它与触摸/手势工作?我看到在苹果的应用程序,控制等都留在ipad屏幕上...

Is this supposed to redirect everything to the external monitor? How dows it work with touches/gestures? I see in the Apple apps, the controls etc are left on the ipad screen...

推荐答案

UIWindow实例为您正在显示的每个屏幕(iPad,外部监视器等)。而不是简单地将您的主UIWindow的屏幕设置为外部显示,您将需要为该显示创建一个不同的UIWindow,并可能将您的视图从iPad窗口移动到外部显示窗口。否则,您将无法在iPad屏幕上接收用于控制远程显示内容的触摸输入。

You need to have a separate UIWindow instance for each screen you are displaying onto (iPad, external monitor, etc.). Rather than simply set your main UIWindow's screen to the external display, you'll want to create a distinct UIWindow for that display and possibly move your views from the iPad window to the external display window. Otherwise, you won't be able to receive touch input on the iPad screen for controlling what's displayed remotely.

例如,以下代码将在外部显示( externalScreen 是相应的UIScreen实例):

For example, the following code will create a new window on an external display (with externalScreen being the appropriate UIScreen instance):

CGRect externalBounds = [externalScreen bounds];
externalWindow = [[UIWindow alloc] initWithFrame:externalBounds];

UIView *backgroundView = [[UIView alloc] initWithFrame:externalBounds];
backgroundView.backgroundColor = [UIColor whiteColor];

[externalWindow addSubview:backgroundView];

[backgroundView release];

externalWindow.screen = externalScreen;
[externalWindow makeKeyAndVisible];

您还需要在应用程序中监视屏幕连接/断开连接事件, 。为此,请监听 UIScreenDidConnectNotification UIScreenDidDisconnectNotification

You will also want to watch for screen connection / disconnection events in your application, and deal with them appropriately. To do this, listen for the UIScreenDidConnectNotification and the UIScreenDidDisconnectNotification.

我有一个粗略的例子,在我的 Molecules iPhone / iPad应用程序的最新代码中工作,如果你想看到一种处理外部显示器的方法。

I have a crude example of this working within the latest code of my Molecules iPhone / iPad application, if you want to see one way of handing the external display.

这篇关于将ipad连接到外部显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆