I woud post this as a comment, but I'm unable to do so.
Is the main view controller that should call dismissModelViewControllerAnimated:. You can either call [[self parentViewController]dismissModalViewControllerAnimated:] in the presented view controller or define a method in a protocol that dismiss the modal view controller and implement the protocol in the main view controller, set it as the delegate of the presented view controller and call the method from it. You are doing it the wrong way. It might or might not solve your issue.
Update (code sample isn't available on comments):
On the MainViewController you should have something like this
- (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];
}
while on the detail view controller presented as modal view controller, the only thing needed is something like this
-(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.
}
but if the application is running fine on iPhone, it should run just as fine on the iPad as iPhone app.