Ios – Xcode storyboard: Why does the iPad storyboard show iPhone sized views

interface-builderiosstoryboardxcode

I have a universal app that uses storyboards. There is an iPhone storyboard and an iPad storyboard. However, in interface builder, the viewcontrollers for the iPad storyboard are still sized for the iPhone. How do I get the iPad storyboard to show iPad sized view controllers?

I realize that the view controller display in interface builder is design-time-only eye-candy, but having iPhone sized VCs makes it really hard to lay out the UI correctly.

Best Answer

After some digging through the storyboard source code, it turns out that the iPad storyboard was copied from the iPhone storyboard. So, the question really became how do I convert an iPhone storyboard into an iPad storyboard?

The answer is surprisingly simple. I ran across this SO answer -- to convert an iPhone storyboard to an iPad storyboard, do the following:

  1. From Xcode, right-click on the storyboard and choose Open As -> Source code

  2. Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad"

  3. Right-click on the storyboard again and choose Open As -> iOS Storyboard

The storyboard will now show all views in the correct size.

Related Topic