Iphone 第一次启动时以模式显示视图控制器

Iphone 第一次启动时以模式显示视图控制器,iphone,uiviewcontroller,uimodaltransitionstyle,Iphone,Uiviewcontroller,Uimodaltransitionstyle,我想在应用程序第一次打开时查看如何使用我的应用程序的说明。我已经处理了仅在第一次启动时使用NSUserDefaults显示此视图的问题,但我很难让视图以我希望的方式显示,而不是以rootViewController的方式显示。以下是我的AppDelegate.m代码: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

我想在应用程序第一次打开时查看如何使用我的应用程序的说明。我已经处理了仅在第一次启动时使用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。我希望能够单击指令ViewController导航栏上的“完成”以转换回rootViewController。按编写的方式执行代码永远不会显示“指令”视图。查看说明viewController的唯一方法是更改行[self.viewController presentModalViewController:howtoNavController animated:NO]
self.window.rootViewController=self.instructionsViewController但这显然不是我想要的(除非我可以转换回viewController)


希望我已经足够清楚地表明了我想要实现的目标。提前感谢。

尝试移动
[self showInstructions]
applicationIDBECOMEACTIVE:

尝试将
[self show指令]
放在
[self.window makeKeyAndVisible]之后。

[self.window makeKeyAndVisible];

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

哇!非常感谢你。我不认为我会想到那样做。