Matt Gemmell

iPad VGA Output

1 min read

There’s been a lot of confusion about how the iPad VGA Adapter works. I received mine today, and I thought I’d try to clear things up a little (and give you some code to play with, if you’re an iPad developer with a VGA adapter of your own).

The first thing to understand is that the adapter does not mirror your iPad screen. You can’t plug your iPad into your TV or monitor and see all your apps on the big screen, like Steve Jobs does when he’s giving a demo.

Apps that want to support external display via the adapter must explicitly do so; the developer has to write code to support it. There are some standard iPhone OS-supplied APIs which will automatically do the right thing (such as video playback via standard controllers), but generally you won’t see anything on your external display unless the app you’re using has taken steps to put something there. That’s the “bad” (though surely not surprising) news.

The good news is that it’s trivially easy to support external display from your app if you’re a developer; the connected display just shows up as another UIScreen object. I made a sample project (which you can download as a zip archive here) that shows how to do it.

It’s basically just a nib with two windows (one for showing on the iPad, and one for showing on the connected external display), and a tiny bit of code to make it work. When you run it on an iPad with the VGA adapter connected and attached to an external display, you’ll see something a lot like this:

Screenshot of iPad VGA adapter output.

What you’ll see if you run the code on an iPad with the adapter connected.

Note that “VGA” is a bit of a misnomer here, since as you can see the actual output resolution depends on which modes the connected display supports. My code allows you to pick which one to use. Don’t even bother trying to run the code in the Simulator or on an iPad without a VGA adapter connected and attached to a monitor, TV or projector. It’ll be an extremely boring experience if you do. Update: As of the 4.0 SDK, you can now simulate a connected external screen in the iPhone/iPad Simulator, at any of the supported resolutions.

Once again, you can download the source code here.

Hope it comes in handy, and I look forward to seeing the interesting ways you support external displays in your iPad apps!

If you enjoyed this article, you might be interested in following me on Twitter, enquiring about my iPad (and iPhone and Mac) development services, or listening to my thoughts on software design on The MDN Show podcast. I’ll also quite shamelessly link you to my Amazon wishlist.