ユーザー「Flocked」と同様の問題があります(ここで質問を参照してください:AppDelegateのapplicationDidFinishLaunchingから他のビューをロードしてください)が、彼の投稿を読んだ後、どうにかして解決できませんでした。おそらく私の状況は彼とは異なります。
didFinishLaunchingWithOptions
アプリケーションが初めて実行されたかどうかを確認するためのルーチンを内部に持っています(これも別のユーザーから取得しました):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
NSLog(@"First run");
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
InfoView
firstLaunch が発生した場合、別のビュー (セットアップ用のビュー) を読み込めません。私が試してみました:
InfoView *infoView = [[InfoView alloc]init];
[self presentViewController:infoView animated:YES completion:nil];
中身if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"])
しかし運がない。アイデアや助けはありますか?