In my universal application I have a master detail at the beginning. On the iPad it is just shown as a split view and when I change the interface orientation the autosizing works fine. But on the iPhone this doesn't work good enough in my detail view. So I want to have two different views for my DetailViewController that should have the exact same functionality, but I can't really get it to work properly. I tried to use two view controllers, but that didn't really do the job. I am using a storyboard by the way.
I thought I have found a solution by adding two views to my DetailViewController. Then I simply check the current orientation and set the recent view like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Video *currentVideo = [[self.xmlParser videos] objectAtIndex:indexPath.row];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
[self.detailViewController setDetailItem:currentVideo];
else {
if (!self.detailViewController) {
DetailViewController *nextController = [self.storyboard instantiateViewControllerWithIdentifier:@"Detail"];
if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait)
[nextController setView:nextController.portraitView];
else
[nextController setView:nextController.landscapeView];
[nextController setDetailItem:currentVideo];
[self.navigationController pushViewController:nextController animated:YES];
}
}
}
This works like it should, but now I face another problem. The two views contain exactly the same outlets, but I can only connect the outlets of either one of them to my DetailViewController class. So in one of the orientations I can't view my contents properly or I have to code everything twice what is exactly the thing I want to avoid.
Do have any ideas how I could handle this problem?
Thanks in advance