Converting Storyboard from iPhone to iPad in 4 simple steps

Developing a universal iOS app means that you have to maintain two storyboards. Sometimes, all you want is your iPad user interface to be somewhat similar to your iPhone UI. However, making 2 interfaces is a big pain and a mega resource expender. The solution is simple. Just create your iPhone UI in Xcode as you do, then to make a new storyboard for the iPad without doing unnecessary back breaking, do the following steps:

  1. Make a copy of your iPhone storyboard in Xcode. You can do this by right clicking on the storyboard file in Xcode and selecting “Show in Finder”. Now locate the storyboard file in the finder window that pops (you may have to go into a few folders to find it). Copy the file to desktop and rename it “MainStoryboard_iPad.storyboard”

  2. Now open this file “MainStoryboard_iPad.storyboard” in a text editor like Text Wrangler or Sublime Text etc.

  3. Now perform the following 2 search and replaces in the “MainStoryboard_iPad.storyboard” file:

  • Search for

    targetRuntime="iOS.CocoaTouch"

    and replace it with

    targetRuntime="iOS.CocoaTouch.iPad"

     

    • Search for

      <simulatedScreenMetrics key="destination" type="retina4"/>

      and replace it with

      <simulatedScreenMetrics key="destination"/>

 

  1. Save the file. Reopen Xcode and add this file to the project either by dragging and dropping to the project folder or by going to File -> Add Files to

Now head over to the ‘General’ section by choosing your applications target in Xcode. Under ‘Deployment Info’, choose iPad from ‘Devices’. A pop-up will appear asking if you want to copy the iPhone interface and use it for iPad. Choose ‘Dont Copy’. Now from the ‘Main Interface’ drop down menu, choose “MainStoryboard_iPad.storyboard” .

And done!

You may have to re-arrange all the views in your interface but thats not really much of a headache compared to creating a new UI from scratch.

Inspiration for this post: http://stackoverflow.com/questions/8465769/converting-storyboard-from-iphone-to-ipad

 

comments powered by Disqus