【发布时间】:2012-11-19 00:26:43
【问题描述】:
我正在开发一个通用应用程序,我想支持 iOS 6、iOS 5 和 iPhone 5。我打算用不同的 Storyboard 来做到这一点,但问题是如何在 AppDelegate 中切换 Storyboard。我试过这个:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
float currentVersion = 6.0;
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion == NO) {
if (iOSDeviceScreenSize.height == 480)
{
UIStoryboard *ios5iphone = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone-ios5" bundle:nil];
}
else
{UIStoryboard *ios5iphone = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad-ios5" bundle:nil];}
}
return YES;
}
我有 4 个故事板(iPhone 4/5 带有适用于 iOS 6 的自动布局,iPad 带有适用于 iOS 6 的自动布局,iPhone 4 适用于 iOS 5 和 iPad 用于 iOS 5)
我的问题是如何在应用程序启动之前切换故事板。
错误:
2012-11-18 13:42:42.471 iEveryTech[22902:c07] Unknown class Firs in Interface Builder file.
2012-11-18 13:42:42.494 iEveryTech[22902:c07] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x1632052 0xfaed0a 0x15daa78 0x15da9e9 0x43b7d7 0x43b9af 0x43b6b7 0x33c36d 0x1e3e2c 0x1e43a9 0x1e45cb 0x1ffb89 0x1ff9bd 0x1fdf8a 0x1fde2f 0x1fbffb 0x1fc85a 0x1e5fbf 0x1e621b 0x1e70f1 0x155fec 0x15b572 0x15572b 0x144bc2 0x144ce2 0x144ea8 0x14bd9a 0x11cbe6 0x11d8a6 0x12c743 0x12d1f8 0x120aa9 0x17c5fa9 0x16061c5 0x156b022 0x156990a 0x1568db4 0x1568ccb 0x11d2a7 0x11ea9b 0x228d 0x21b5 0x1)
terminate called throwing an exception(lldb)
【问题讨论】:
-
将
return语句放在方法的末尾。请澄清您的问题。 -
@Mat 我的问题是如何切换故事板
-
是的,但我的意思是你的代码有什么问题。运行代码时会发生什么?你能看到至少一个控制器吗?你把return语句放在最后了吗?
-
@Mat 我没有看到控制器,每次应用程序加载时模拟器都会崩溃,这与我在 iOS 5 中检查“使用自动布局”时的错误相同,我认为代码是错误的。你有什么想法吗?
-
所以请至少发布错误消息或任何有助于理解您的问题的内容。