ナビゲーションベースのiPhoneアプリを持っています。通常、RootViewControllerから開始します。そこで、UITableViewから行を選択して、別のViewControllerに移動できます。これを、SecondLevelViewControllerと呼びます。
アプリが起動したら、SecondLevelViewControllerから終了したかどうかを確認します(defaultUserSettingsに保存されたパラメーターを使用)。もしそうなら、私はそのSecondLevelViewControllerをもう一度表示したいと思います。
これを実現するために、アプリケーションデリゲートでチェックインを行います
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
メソッド、直後
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
次に、SecondLevelViewControllerをビュースタックに追加します。pushViewControllerとsetViewControllersで試してみました。
SecondLevelViewController *newVC = [[SecondLevelViewController alloc] initWithNibName:@"SecondLevelView" bundle:nil];
[self.navigationController setViewControllers:[NSArray arrayWithObjects:[self.navigationController.viewControllers objectAtIndex:0], newVC, nil]
animated:YES];
その後、アプリは目的のビューを表示します。ここで問題があります。SecondLevelViewControllerはナビゲーションバーの左側に戻るボタンを表示します。上記の方法を使用している場合、このボタンは表示されません。私の結論は、SecondLevelViewControllerに移動した時点では、RootViewControllerはまだ完全には初期化されていないということです。これは可能ですか?どうすればこれを回避できますか?
ありがとう、マーク。