UINavigationController を使用して、一種の「左から右」の階層ナビゲーションを実現しようとしています。私はこのコードを使用しています:
-(IBAction)showSettings:(id)sender {
UINavigationController *aNavController = [[UINavigationController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:aNavController animated:YES];
SecondView *secondView = [[SecondView alloc] initWithNibName:nil bundle:nil];
[aNavController pushViewController:secondView animated:NO];
UIBarButtonItem *aButton = [[UIBarButtonItem alloc] initWithTitle:@"Knapp" style:UIBarButtonItemStylePlain target:self action:@selector(nextView:)];
aNavController.topViewController.navigationItem.rightBarButtonItem = aButton;
[aButton release];
[secondView release];
[aNavController release]; }
-(IBAction)nextView:(id)sender {
ThirdView *thirdView = [[ThirdView alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:thirdView animated:YES];
NSLog(@"Push it like it's hot"); }
「nextView」が正しく呼び出され、「Push it like it's hot」が「Output」に出力されますが、何もプッシュされず、新しいビューは表示されません。変更も試みまし
[self.navigationController pushViewController:thirdView animated:YES];
た[self.navigationController popViewControllerAnimated:YES];
が、結果は同じままで、何も起こりません。
私の結論は次のとおりです。「nextView」の self.navigationController 部分で何か間違ったことをしています。つまり、プログラムは何をプッシュ/ポップするかを認識していません。これについて何らかのドキュメントを調べるために最善を尽くしましたが、うまくいかないので、ここにいます。
self.navigationController はそれを行う正しい方法ですか、それともその行に何かが欠けていますか?
前もってありがとう、トビアス・トベダル