如何加载多个故事板文件,这取决于IOS版本? (5和6) [英] How to load multiple storyboard files depending on iOS version? (5 and 6)
问题描述
我有我试图做出的iOS 6和iOS 5兼容的标签栏控制器应用程序。
对于iOS 6,我使用自动布局。
但是,试图在iOS 5上运行的时候,我得到一个错误,由于它不承认NSLayoutConstraints。
I have a tab bar controller app that I am trying to make compatible for iOS 6 and iOS 5. For iOS 6, I use auto layout. But when trying to run on iOS 5, I get an error due to it not recognizing NSLayoutConstraints.
从我可以告诉,我需要使用无自动布局不同的故事板启用。我抄我的故事板到一个新的,但不知道如何设置这些故事情节在应用程序的委托来使用。
From what I can tell, I am required to use a different storyboard without auto layout enabled. I have copied my storyboard into a new one, but don't know how to set which storyboard to use in the app delegate.
请告诉我code做到这一点?
Whats the code to do this?
推荐答案
在您的应用程序委托,你应该找到code是这样的:
In your app delegate, you should find code like this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil];
self.window.rootViewController = [storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
这是您可以在其中添加一些code,你必须几个故事板取决于iOS版<版本中进行选择/ A>
This is where you can add some code to choose among the several storyboards that you have depending on the version of iOS:
UIStoryboard *storyboard;
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if (...) {
storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard-v5" bundle:nil];
} else {
storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard-v6" bundle:nil];
}
self.window.rootViewController = [storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
这篇关于如何加载多个故事板文件,这取决于IOS版本? (5和6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!