如何根据 iOS 版本加载多个故事板文件?(5和6)

How to load multiple storyboard files depending on iOS version? (5 and 6)(如何根据 iOS 版本加载多个故事板文件?(5和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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

AWS DynamoDB Batch Get Request - iOS(AWS DynamoDB 批量获取请求 - iOS)
Querying DynamoDB on non-key attributes(在非关键属性上查询 DynamoDB)
DynamoDB auto incremented ID amp; server time (iOS SDK)(DynamoDB 自动递增 ID amp;服务器时间(iOS SDK))
Where to find a clear explanation about swift alert (UIAlertController)?(哪里可以找到关于 swift alert (UIAlertController) 的清晰解释?)
Facebook Requests Dialog: Frictionless Requests in native iOS app possible?(Facebook 请求对话框:本机 iOS 应用程序中的无摩擦请求可能吗?)
dynamodb scanexpression with scan filter in objective-c(在objective-c中带有扫描过滤器的dynamodb scanexpression)