How to load multiple storyboard files depending on iOS version? (5 and 6)(如何根据 iOS 版本加载多个故事板文件?(5和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.
执行此操作的代码是什么?
Whats the code to do this?
推荐答案
在您的应用程序委托中,您应该找到如下代码:
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];
您可以在此处添加一些代码以在您拥有的几个故事板中进行选择取决于 iOS 的版本:
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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何根据 iOS 版本加载多个故事板文件?(5和6)
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01