Output iPad content to external display

As little indicates, you'll need to create a new UIWindow and attach it to the UIScreen for the external display. This UIWindow will host the content to be presented on the external display, so you'll need to build a distinct view hierarchy for that, separate from your main application interface. You also will need to listen for the UIScreenDidConnectNotification and UIScreenDidDisconnectNotification notifications that inform your application when the external display has been attached and removed.

I demonstrate how to do this in the video for the iPad session of my class on iTunes U, for which the course notes can be viewed here.

Matt Gemmell also did a very nice writeup on this recently, which you can read here.


The key to implementing this feature is contained in the UISCreen class:

http://developer.apple.com/iphone/library/documentation/uikit/reference/UIScreen_Class/Reference/UIScreen.html#//apple_ref/occ/clm/UIScreen/screens

Basically, your app will use UIScreen to get access to the external display screen and then set it as the screen for a new UIWindow (your app will have two UIWindows). The app can then add a ViewController to the new UIWindow that represents the second screen and off you go.

UIWindow *externalWindow.screen = [[[UIScreen screens] lastObject] retain];
[externalWindow addSubview:externalViewController.view];

It's pretty simple, but will take a little experimenting to get it working. It's a pain in the butt to debug your app on the device, since the 30-pin connector will be required to connect to the display, so cannot also be used for debugging. Perhaps there is a pass thru cable for allowing debug + external display, but I haven't had a chance to look.

Limitations: You should be able to output video-quality bit rates, as apple has been able to achieve this with a few of their applications. That said, the external display will be limited to the screen resolution supported by the device, so things might not look crisp on your 108" LCD :-)

Platforms: This should work on all iPads and on iPhones running 4.0+. You'll need the special cable which I believe is unique for iPhone and iPad ($30-40).

Tags:

Iphone

Ipad