2012-02-15 15 views
0

初めてアプリケーションを使用する方法の説明を表示したいと思います。私はNSUserDefaultsを使用して最初の起動時にこのビューを表示するだけの問題を処理しましたが、私はrootviewControllerとしてではなく、モーダルに表示する方法を表示するのに問題があります。ここに私のAppDelegate.mコードは次のとおりです。最初の起動時にモーダルに表示コントローラを表示する

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease]; 

    self.window.rootViewController = self.viewController; 

    BOOL hasShownStartup = [[NSUserDefaults standardUserDefaults] boolForKey:kAppHasShownStartupScreen]; 

    if (!hasShownStartup) { 
     [self showInstructions]; 
    } 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 

- (void)showInstructions 
{ 
    NSLog(@"showing instructions"); 
    InstructionsViewController *howToView = [[InstructionsViewController alloc] initWithNibName:@"InstructionsViewController" 
                        bundle:nil]; 
    self.instructionsViewController = howToView; 
    [howToView release]; 
    UINavigationController *howtoNavController = [[UINavigationController alloc] 
              initWithRootViewController:self.instructionsViewController]; 
    self.instructionsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self.viewController presentModalViewController:howtoNavController animated:NO]; 
    [howtoNavController release]; 
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kAppHasShownStartupScreen]; 
} 

私は私のrootViewControllerがself.viewControllerままにしておきたいです。私はinstructionsViewControllerのナビゲーションバーで '完了'をクリックして、rootViewControllerに戻ることができるようにしたいと考えています。書かれたコードを実行すると、命令ビューは表示されません。私がinstructionsViewControllerを見ることができる唯一の方法は、[self.viewController presentModalViewController:howtoNavController animated:NO];self.window.rootViewController = self.instructionsViewController;に変更することですが、これは明らかに私が望むものではありません(私がモーダルに戻ってviewControllerに戻ることができない限り)。

私が達成しようとしていることを十分に明確にしました。前もって感謝します。

答えて

2

代わりに[self showInstructions];applicationDidBecomeActive:に移動してみてください。

+0

うわー。どうもありがとうございます。私はそれをすると思ったとは思わない。 –

0

[self.window makeKeyAndVisible][self showInstructions]を入れてみてください:

[self.window makeKeyAndVisible]; 

if (!hasShownStartup) { 
    [self showInstructions]; 
} 
関連する問題