0

複数のストーリーボード アプリを作成しています。要件に基づいて、さまざまなインスタンスでさまざまなストーリー ボードを使用しています。すべてのデバイスをサポートするには、次のようにコードを記述する必要があります。

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];

チルダ (~) も使用して、ストーリーボードにblah~iphone&のような名前を付けてみましたが、次のblah~ipadようなエラーがスローされます:

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

何か案が??

4

1 に答える 1

0

何かが足りないのかもしれませんが、ストーリーボード ファイルを使用している場合にウィンドウを手動で管理している理由がわかりません。

既存のプロジェクトにユニバーサル サポートを追加していると思います。新しいユニバーサル アプリを作成すれば、すべてが必要なだけになるからです。

application:didFinishLaunchingWithOptions:次のように、アプリのデリゲートにメソッドが必要です。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

ターゲット設定は次のようになります。iPhone / iPad の切り替えに注意し、デバイスごとに異なるストーリーボードを選択してください。

ここに画像の説明を入力

于 2014-01-21T14:36:03.460 に答える