このサイトのすべての質問の中でさえ、解決策を見つけることができなかった popToRootViewControllerAnimated にこの問題があります。
基本的に、メインのタブバーがあり、各タブに UIViewController があります。タブの 1 つに、次の画面に移動するためのボタンがあります (たとえば、B)。Bビューコントローラーには、次のビューコントローラー、たとえばCに移動するための別のボタンがあります。私が達成しようとしているのは、ワンクリックでCからAに戻ることです。それは私のコードです:
A から B に移動するには、次のようにします。
ExerciseNextScreen *exerciseNextScreen = [[ExerciseNextScreen alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:exerciseNextScreen animated:YES];
次に、B から C まで、次のようにします。
ScreenOneExercise *screenOneExercise = [[ScreenOneExercise alloc] initWithNibName:nil bundle:nil];
UINavigationController *screenOneExerciseNav = [[UINavigationController alloc]initWithRootViewController:screenOneExercise];
[self presentModalViewController:screenOneExerciseNav animated:YES];
さて、C では、A に戻ろうとしているときにそれを行います。
- (IBAction)cancelView:(id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
cancelView メソッドに入ると、何も起こりません。この呼び出しの直前に self.navigationController をチェックしましたが、nil ではありません。
どうすればAビューコントローラーに戻ることができますか? このフォーラムですべてを試しましたが、役に立ちませんでした。
ありがとう。