I setup a project on XCode 4.3 and IOS 5 without using storyboards for both iPhone and iPad using the default Master/Detail setup from the create new project dialog.
The iPhone side works just fine. I select an option in the tableView and the detailViewController screen updates with the new information based on the selection.
My implementation of didSelectRowAtIndexPath is:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Shapes *currentShape = [self.shapesArray objectAtIndex:indexPath.row];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (!self.detailViewController) {
self.detailViewController = [[[GeoDetailViewController alloc] initWithNibName:@"GeoDetailViewController_iPhone" bundle:nil] autorelease];
}
[self.navigationController pushViewController:self.detailViewController animated:YES];
[self.detailViewController populateDisplay:currentShape];
} else {
[self.detailViewController populateDisplay:currentShape];
}
}
However, when I run on the iPad, self.detailViewController does not exist. so the display doesn't update. I can still see it on the iPad screen, I just can't change anything on it. How do I reference it in the code so I can make changes to what is displayed?
I was puzzled by the templates implementation of the Master/Detail view. I asked a similar question:
How to update DetailView using MasterDetail Application Template
You can use the detailItem (id - so you can pass in a reference) property that is set up by default for the DetailViewController class.