I have a project created in Xcode 5. The "Deployment Info" settings says Devices: Universal but has separate iPhone and iPad settings and corresponding iPhone and iPad storyboards.
Now I'm developing the same project in Xcode 6 and I want to use one universal storyboard instead of two storyboards. I have only worked on the iPhone storyboard and haven't touched the iPad one. Is it possible to ditch the iPad storyboard and convert the existing iPhone storyboard to be my main universal storyboard?
I found a simple solution and it worked for me.
Duplicate your
MainStoryboard
and rename asMainStoryboard_iPad.storyboard
from theFile
menuNow Right click on your MainStoryboard_iPad file and click on
open as a source code
.You will get an XML document. Now make some changes in XML file as below.
Search for
targetRuntime="iOS.CocoaTouch"
and change it totargetRuntime="iOS.CocoaTouch.iPad"
Remove The type =
"retina4"
as From<simulatedScreenMetrics key="destination" type="retina4"/>
toAgain open the
MainStoryboard_iPad
file in interface builder. Hurray... You will get your iPad version storyboard. Now you just need to change the width and height as per your Layout.This helped me alot and saved alot time.
:) Im sure it will help you!
I adapted this tutorial and a similar solution by @tharkay to create this solution below.
Main_iPhone.storyboard
toMain.storyboard
Main_iPad.storyboard
Main_iPad.storyboard
toMain.storyboard
and delete theMain_iPhone.storyboard
file. You will then need to go to the File Inspector and right-click your storyboard, then select “Open as Source Code”. This will display all that XML code. ChangetargetRuntime
from"iOS.CocoaTouch.iPad"
to"iOS.CocoaTouch"
From:
to:
Main.storyboard
for both iPhone and iPad.Main.storyboard
, on the right-hand panel choose theShow the File inspector
icon.Use Size classes
In xCode 9 I also had to add
useTraitCollections="YES"
property into document tag (same place wheretargetRuntime="iOS.CocoaTouch"
is).