ストーリーボードとナビゲーション コントローラーを使用するアプリがあります。アプリ フローのある段階で、ビュー スタックに約 4 つのビューを取得します。その時点で、ルート ビューに到達するまですべてのビューをポップオフする必要があります。その後、別のビューを手動でプッシュする必要があります。
私は運が悪いので、さまざまなことを試しました。組み込みの API 呼び出しを使用しようとしました。
[self.navigationController popToRootViewControllerAnimated:YES];
その時点で、ルート ビューを参照してセグエ メソッドを呼び出して、プッシュ セグエを呼び出そうとします。
RootView *obj = [[RootView alloc] init];
[obj callSegue];
または
[self.navigationController performSegueWithIdentifier:@"pushView" sender:self];
とにかく、私はこれに完全に困惑しています。誰でも助けることができますか?
アップデート:
返信ありがとうございます。私はもう少し掘り下げていて、解決策を見つけました。確かに多くの解決策の1つです。
// Reference to navigation controller. Apparently if you use self.navigationController in a popToRootViewController call it sets self.navigationController to nil.
UINavigationController *navigationController = self.navigationController;
[navigationController popToRootViewControllerAnimated:NO];
// Reference to view to push - must set storyboard ID in inspector
ViewToPush *viewRef = (ViewToPush *)[self.storyboard instantiateViewControllerWithIdentifier:@"gameView"];
[navigationController pushViewController:gameView animated:NO];