コメントとして投稿しますが、できません。
dismissModelViewControllerAnimatedを呼び出す必要があるメインビューコントローラーです: 。提示されたビューコントローラーで[[selfparentViewController]dismissModalViewControllerAnimated:]を呼び出すか、モーダルビューコントローラーを閉じてメインビューコントローラーにプロトコルを実装するプロトコルでメソッドを定義し、提示されたビューコントローラーのデリゲートとして設定できます。そこからメソッドを呼び出します。あなたはそれを間違った方法でやっています。それはあなたの問題を解決するかもしれないし、しないかもしれません。
更新(コードサンプルはコメントでは利用できません):
MainViewControllerには、次のようなものがあります。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// In this case is inside a tableviewmethod, but it could really be an action associated with a button.
DetailViewController *controller = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
[controller setDelegate:self]; // The delegate is the parent and is assigned, not retained.
// Modal presentation style is only used on iPad. On iPhone is always full screen.
// [controller setModalPresentationStyle:UIModalPresentationFullScreen];
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:controller animated:YES];
[controller release]; // It will be deallocated upon dismissal.
}
-(void)dismissDetailViewControllerAndProcessData:(NSDictionary *)data {
// Do something with the data passed.
[self processData:data];
// Dismiss the modalviewcontroller associated with this viewcontroller.
[self dismissModalViewControllerAnimated:YES];
}
モーダルビューコントローラーとして表示される詳細ビューコントローラーでは、必要なのは次のようなものだけです。
-(void)actionBack:(id)sender {
// Call the delegate method. If you just need to dimiss the controller, just
// call
// [[self parentViewController]dismissModalViewControllerAnimated:YES];
// and don't even bother to set up a delegate and a delegate method.
[delegate dismissDetailViewControllerAndProcessData:nil]; // Call the parent dismissal method.
}
ただし、アプリケーションがiPhoneで正常に実行されている場合は、iPadでもiPhoneアプリと同じように正常に実行されるはずです。