「問題なく」動作していたいくつかのモーダル ビューがあり、現在は親ビュー コントローラーに戻るのをやめ、「コードは変更されていません」。-- 古典的な問題の説明。
モーダル ビューの非表示をデバッグしましたが、親ビュー コントローラーは nil です。これは問題を説明していますが、原因は説明していません。SDK を 4.1.2 から 4.2 にアップグレードしたので、iOS 5 での作業を開始できます。新しいメモリ管理 ARC と、自動解放と保持/解放の私のスタイルに疑いがあります。
以下は、ルートビュー コントローラーから AboutViewController へのコードです。
- (IBAction)doInfo:(id)sender {
NSLog(@"%s", __FUNCTION__);
AboutViewController *aboutViewController = [[[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:[NSBundle mainBundle]] autorelease];
if (aboutViewController) {
aboutViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
aboutViewController.hidesBottomBarWhenPushed = YES;
self.navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
self.navigationController.navigationBarHidden = YES;
[self presentModalViewController:aboutViewController animated:YES];
}
}
以下は、「完了」ボタンを押した後、AboutViewController を閉じてその親に戻します。
- (IBAction)doDone:(id)sender {
NSLog(@"%s", __FUNCTION__);
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
わかりました...次のように変更して修正しました。問題は、なぜこれが以前に機能したのかということです。
- (IBAction)doDone:(id)sender {
NSLog(@"%s", __FUNCTION__);
[self dismissModalViewControllerAnimated:YES];
}