我想看看如何在第一次打開應用程序時使用我的應用程序顯示的說明。我已經處理了使用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)。
希望我已經明確了我想要完成的事情。提前致謝。
哇。非常感謝。我不認爲我會這麼想。 – 2012-02-15 21:04:30