how to develop for iPhone and iPad in separated storyboards Xcode6

大城市里の小女人 提交于 2019-12-23 04:35:32

问题


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

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)

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)


回答1:


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.

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: 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).




回答2:


That still work for me... but I use a Deployment Target 6.0 And my last release is special for iOS 8.1 and iPhone 6. I fear this may be the only solution :-( You can after chose 8.1 in others parameters for compiler, storyboards, etc.



来源:https://stackoverflow.com/questions/26684476/how-to-develop-for-iphone-and-ipad-in-separated-storyboards-xcode6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!