如何在单独的故事板 Xcode6 中为 iPhone 和 iPad 开发 [英] how to develop for iPhone and iPad in separated storyboards Xcode6

查看:31
本文介绍了如何在单独的故事板 Xcode6 中为 iPhone 和 iPad 开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xcode5 中,我有两个故事板,一个用于 iPad,一个用于 iPhone

in Xcode5 I had two storyboards, one for iPad and one for iPhone

这听起来更容易观看 viewControllers 的流程,因为在 iPhone 上你不能做你在 iPad 上做的同样的事情(UIPopoverControllers 和其他很酷的东西)

that sounds easier to watch the flow of the viewControllers, and because on iPhone you can't do the same thing you do in iPad (UIPopoverControllers, and other cool stuff)

现在在 Xcode6 中实现了通用故事板,这对某些人来说很好,但是如果你想继续使用分离的故事板,我看不到为 iPhone 设置一个故事板和为 iPad 设置另一个故事板的选项,我只看到这个:

now in Xcode6 implemented universal storyboards which is good for some people, but what if you want to keep using separated storyboards, I can't see the option to set one StoryBoard for iPhone and other for iPad, all I see is this:

只是一个主界面......如何改变它以前的样子???(两个故事板)

just a main interface... how to change this as it was before??? (two storyboards)

推荐答案

从 XCode 6 开始,不再有一种为不同设备制作故事板的集成方法,但您可以在您的应用委托中手动修改以使用两个不同的故事板.

As of XCode 6, there is no longer an integrated way to do storyboards for different devices, but you can do a manual hack in your app delegate to use two different storyboards.

首先,创建您的第二个故事板.您现在应该有两个故事板:Main~iPhone.storyboardMain~iPad.storyboard(名称并不重要).

First, create your second storyboard. You should have two storyboards now: Main~iPhone.storyboard and Main~iPad.storyboard (the names don't really matter).

然后在您的应用委托中执行以下操作:

Then in your app delegate do this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    UIStoryboard *storyboard;
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        storyboard = [UIStoryboard storyboardWithName:@"Main~iPad" bundle:nil];
    } else {
        storyboard = [UIStoryboard storyboardWithName:@"Main~iPhone" bundle:nil];
    }
    self.window.rootViewController = [storyboard instantiateInitialViewController];
    [self.window makeKeyAndVisible];
    return YES;
}

(PD:您应该了解 自适应 UI 而不是遵循这种方法.您将能够使用 UIPopOvers 和所有 iPad 的东西与一个通用故事板 - iPhone 可以事情就不一样了.例如,当您在 iPad 中选择弹出窗口时,iPhone 将显示一个模态视图).

(PD: You should learn about Adaptive UIs instead of following this approach. You would be able to use UIPopOvers and all the iPad's stuff with one universal storyboard - The iPhone would do things differently. For example, when in an iPad you choose to do a pop over, the iPhone will display a modal view).

这篇关于如何在单独的故事板 Xcode6 中为 iPhone 和 iPad 开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆