2012-03-22 7 views
7

私はプログラムでストーリーボードに電話をかけようとしています。 マイストーリーボードの構成は次のとおりです。プログラムでデリゲートでストーリーボードを呼び出す

[ナビゲーションコントローラ] - > [MainMenuView] - > [たDetailsView]

"メインメニュー" の識別子が[Ma​​inMenuView]

にi」は、問題を置きました。 m havingは空白を示す画面です。私は何をする必要がありますか?

ありがとうございました。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{  
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 

    MainMenuView *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"MainMenu"]; 

    return YES 
} 

答えて

2

あなたはあなたのアプリケーションのウィンドウのrootViewControllerプロパティを設定する必要があります。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{  
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    MainMenuView *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"MainMenu"]; 

    self.window.rootViewController = rootViewController; 

    return YES; 
} 
+0

私はそれを設定しているが、それはまだ空白 – RockBaby

+0

@RockBaby:AppDelegateの 'window'プロパティがまだ設定されていない、あなたはnilをメッセージングています。 didFinishでこれを最初に行います: 'self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];' – Josh

16

あなたが最初に手動でウィンドウを作成してから(前の回答はほぼ正しかった)、それにrootViewControllerを追加する必要があります。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 

    UIViewController *mainViewController = [storyboard instantiateInitialViewController]; 

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    self.window.rootViewController = mainViewController; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 
+0

これはもはやios 9では当てはまりません –

関連する問題