Wouldn't it be nice if we can demo our iPhone apps on a big screen TV monitor the way Steve Jobs does at Apple conferences? 

Well, some smart people have figured out a way to do this by using an undocumented API in the iPhone SDK. Erica Sadun posted the documentation for this API. Rob Terrell developed the original code for this unit. Kim Ahlberg improved upon it by adding support for on-the-fly orientation changes and touch indicators. He has kindly shared his code at TvOutSample.zip..

Here are simple step to implement this in your own code (*).
  • Download this file UIApplication_TVOut.m and add it to your project
  • Add MediaPlayer.framework to the project

  • Add the following line in the AppDelegate's applicationDidFinishLaunching method after [Windows makeKeyVisible];

    [[UIApplication sharedApplication] performSelector:@selector(startTVOut)];

  • Add the following method to the AppDelegate:

    - (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
    {
         [[UIApplication sharedApplication] performSelector:@selector(reformatTVOutOrientation)];    
    }


  • Build the project
(*) You can not submit this app to the App Store since it uses undocumented APIs. But you can use it to build your own ad-hoc apps for demos.

You will also need one of these cables to connect the iPhone to the TV:

 Apple Component AV Cable: http://store.apple.com/us/product/MB128LL/B

 Apple Composite AV Cable: http://store.apple.com/us/product/MB129LL/B