Ios 如何为iPhone&;使用相同的故事板名称;多功能板通用应用程序中的iPad?

Ios 如何为iPhone&;使用相同的故事板名称;多功能板通用应用程序中的iPad?,ios,nsstring,storyboard,ios-universal-app,tilde,Ios,Nsstring,Storyboard,Ios Universal App,Tilde,我正在创建一个多故事板应用程序。根据要求,我在不同的情况下使用不同的层板。为了支持所有设备,我必须这样编写代码: if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPhone" bundle:nil]; self.window.rootV

我正在创建一个多故事板应用程序。根据要求,我在不同的情况下使用不同的层板。为了支持所有设备,我必须这样编写代码:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPhone" bundle:nil];
   self.window.rootViewController = [storyboard instantiateInitialViewController];
}
else
{         
  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPad" bundle:nil];
  self.window.rootViewController = [storyboard instantiateInitialViewController];
}
[self.window makeKeyAndVisible];
2014-01-21 17:05:44.941 test[2709:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/3D8EC72E-D20D-4C60-A413-E8040A455262/blah.app> (loaded)' with name 'UIViewController-aYh-JW-qLA' and directory 'blah.storyboardc''
*** First throw call stack:
(0x2d4edf4b 0x37c846af 0x2d4ede8d 0x2ffbfe39 0x3010c03d 0x40ff5 0x2fcd12ff 0x2fcd0d4f 0x2fccb353 0x2fc6641f 0x2fc65721 0x2fccab3d 0x3211670d 0x321162f7 0x2d4b89df 0x2d4b897b 0x2d4b714f 0x2d421c27 0x2d421a0b 0x2fcc9dd9 0x2fcc5049 0x4134d 0x3818cab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}
我也尝试过使用tilde(~),将故事板命名为
blah~iphone
&
blah~ipad
,但它会抛出如下错误:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPhone" bundle:nil];
   self.window.rootViewController = [storyboard instantiateInitialViewController];
}
else
{         
  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPad" bundle:nil];
  self.window.rootViewController = [storyboard instantiateInitialViewController];
}
[self.window makeKeyAndVisible];
2014-01-21 17:05:44.941 test[2709:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/3D8EC72E-D20D-4C60-A413-E8040A455262/blah.app> (loaded)' with name 'UIViewController-aYh-JW-qLA' and directory 'blah.storyboardc''
*** First throw call stack:
(0x2d4edf4b 0x37c846af 0x2d4ede8d 0x2ffbfe39 0x3010c03d 0x40ff5 0x2fcd12ff 0x2fcd0d4f 0x2fccb353 0x2fc6641f 0x2fc65721 0x2fccab3d 0x3211670d 0x321162f7 0x2d4b89df 0x2d4b897b 0x2d4b714f 0x2d421c27 0x2d421a0b 0x2fcc9dd9 0x2fcc5049 0x4134d 0x3818cab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}
2014-01-21 17:05:44.941测试[2709:60b]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在捆绑包中加载NIB:“NSBundle(loaded)”,名称为“UIViewController aYh JW qLA”,目录为“blah.Storyboard C”
***第一次抛出调用堆栈:
(0x2d4edf4b 0x37c846af 0x2d4ede8d 0x2FBFE39 0x301C03D 0x40ff5 0x2fcd12ff 0x2fcd0d4f 0x2fccb353 0x2FC66411F 0x2FC6521 0x2fccab3d 0x3211670d 0x321162f7 0x2d4b89df 0x2d4b897b 0x2d421c27 0x2d421a0b 0x2fcc9dd9 0x2FC5049 0x4134d 0x3818cab7)
libc++abi.dylib:以NSException类型的未捕获异常终止

有什么想法吗???

也许我遗漏了什么,但我不明白如果您使用的是情节提要文件,为什么要手动管理窗口

我认为您正在为一个已经存在的项目添加通用支持。因为如果你创建了一个新的通用应用程序,一切都将符合你的需要

您需要应用程序中的
应用程序:didFinishLaunchingWithOptions:
方法,如下所示:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPhone" bundle:nil];
   self.window.rootViewController = [storyboard instantiateInitialViewController];
}
else
{         
  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"blah_iPad" bundle:nil];
  self.window.rootViewController = [storyboard instantiateInitialViewController];
}
[self.window makeKeyAndVisible];
2014-01-21 17:05:44.941 test[2709:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/3D8EC72E-D20D-4C60-A413-E8040A455262/blah.app> (loaded)' with name 'UIViewController-aYh-JW-qLA' and directory 'blah.storyboardc''
*** First throw call stack:
(0x2d4edf4b 0x37c846af 0x2d4ede8d 0x2ffbfe39 0x3010c03d 0x40ff5 0x2fcd12ff 0x2fcd0d4f 0x2fccb353 0x2fc6641f 0x2fc65721 0x2fccab3d 0x3211670d 0x321162f7 0x2d4b89df 0x2d4b897b 0x2d4b714f 0x2d421c27 0x2d421a0b 0x2fcc9dd9 0x2fcc5049 0x4134d 0x3818cab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}
您的目标设置应该如下所示,注意iPhone/iPad开关,并为每个设备选择不同的故事板


这里似乎有输入错误。
诸如此类。故事板c
注意结尾处的额外
c
。也可以尝试在plist中更改相同的内容file@Desdenova .. 我也这么认为,但事实并非如此。。这是编译器生成的error@Bonnie .. 那也不行。。两把钥匙都是“废话”。尝试了所有选项。如果您正在使用故事板,为什么要手动管理窗口?为什么不返回
YES
并从目标设置中设置主界面文件呢?是的,正是。。你错过了很多东西。我在这里要问的是,如何为两个故事板取一个相同的名字:(是的,我想是的..等等iPhone,等等iPad是你能做的最好的。不..有一些带有波浪(~)符号的概念..只要努力就行了。我想我已经找到了你要找的东西。祝你好运