我正在尝试制作一个我认为在使用前需要指南的应用程序,但是在重新启动应用程序时遇到问题,它会返回到入门视图而不是主视图(UIViewController)我有一个 plist 设置如果用户点击 Start App 它会保存一个布尔值,它会保存一个 YES 布尔值,但是当你第一次启动应用程序时,它默认设置为 A NO Bool。继承人来自 appDelegate 的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"GetStartedCheck.plist"];
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
BOOL myBool = [[myDict objectForKey:@"alreadyUsedApp"] boolValue];
[myDict writeToFile:filePath atomically:YES];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (myBool == NO)
{
self.startedViewController = [[GetStartedViewController alloc] initWithNibName:@"GetStartedViewController_iPhone" bundle:nil];
}
else if (myBool == YES)
{
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
}
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
if (myBool == NO)
{
self.window.rootViewController = self.startedViewController;
}
else if (myBool == YES)
{
self.window.rootViewController = self.viewController;
}
[self.window makeKeyAndVisible];
return YES;
有没有我可以阅读和遵循的教程或任何可以给我建议的人。