Converting Storyboard from iPhone to iPad

2019-01-01 12:00发布

I have an iPhone application which has a storyboard. Now I want to provide an iPad application too. So I asked me whether there is a function which helps me convert my iPhone storyboard to an iPad storyboard.

To be specific:

Is there a similar function or is there only the manual way ?

21条回答
情到深处是孤独
2楼-- · 2019-01-01 12:06

For Xcode10

  1. Just duplicate Main.storyboard

  2. Then re-name files to Main_iPad.storyboard and Main_iPone.storyboard

  3. Set appropriate names in .plist

enter image description here

4.Just select the proper .storyboard to configure enter image description here

查看更多
谁念西风独自凉
3楼-- · 2019-01-01 12:06

You should create a bug report with Apple. You can say it's a duplicate of mine (10167030) which has been open since September 2011. The frustrating thing from my point of view is that the feature existed in Xcode 3...

查看更多
唯独是你
4楼-- · 2019-01-01 12:08

This functionality is now built-in. For example, if one changes the project settings in Deployment Info -> Devices from iPhone to Universal, the following dialog will show up:

enter image description here

查看更多
大哥的爱人
5楼-- · 2019-01-01 12:09

A Different Approach

  1. Add an empty-View-Controller with Navigation-Controller in the iPad-Storyboard

  2. Change the Class to the Class of your first ViewController used for iPhone, "fooViewController"

  3. Add the Storyboard-Identifier in the iPhone-Storyboard "fooViewController_storyboard_identifier" for the first ViewController

  4. Go to "fooViewController.m"

  5. Add bool Variable bool nibWasLoadForIpad=false

  6. Go to viewDidLoad-Method

if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && !nibWasLoadForIpad)
{
    nibWasLoadForIpad=true;
    UIStoryboard* Storyboard_iphone=[UIStoryboard storyboardWithName:@"Main_iPhone" bundle: nil];
    fooViewController *controller = [Storyboard_iphone instantiateViewControllerWithIdentifier:@"fooViewController_storyboard_identifier"];
    [self.navigationController pushViewController:controller animated:YES];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
}

(ps. Know problem is that the view-backgrounds will be set to white)

查看更多
只靠听说
6楼-- · 2019-01-01 12:11

The easiest and most reliable way to do this is to copy paste from your iPad storyboard.

  1. Create a new storyboard and name it something like MainStoryboard_ipad.
  2. Make your app a Universal app by setting the Devices property to Universal on the Summary page of the Target properties for your project. enter image description here
  3. Open your iPhone storyboard and select all and copy
  4. Open your iPad storyboard and paste.

You'll have to go about resizing, but it can be faster than recreating the whole storyboard.

查看更多
孤独寂梦人
7楼-- · 2019-01-01 12:12

That didn't quite work for me. I did something a little bit different.

  1. Create a new story board file for the iPad version
  2. Open both the new file and the file i want to copy in textwrangler (text editor)
  3. Copied the xml text from old file to the new file between these xml tags
  4. First Tag <scenes> <!--Contents View Controller-->
  5. Paste Here
  6. End Tags </class> </classes>

That worked for me. I got a new layoutout with all my outlets connected, which alone saved me a few hours.

查看更多
登录 后发表回答