如何在使用splitViewController的iPad上引用detailViewController [英] How do I reference the detailViewController on an iPad that is using a splitViewController
问题描述
我在XCode 4.3和IOS 5上设置了一个项目,没有使用创建新项目对话框中默认的主/细节设置的iPhone和iPad的故事板。
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.
iPhone端工作得很好。我在tableView和detailViewController屏幕中选择一个选项,根据选择更新新信息。
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.
我的didSelectRowAtIndexPath实现是:
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];
}
}
然而,当我在iPad上运行时,我自己。 detailViewController不存在。所以显示不会更新。我仍然可以在iPad屏幕上看到它,我无法改变任何内容。如何在代码中引用它以便我可以更改显示的内容?
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:
如何使用MasterDetail应用程序模板更新DetailView
您可以使用detailItem(id - 因此您可以传入引用)属性默认情况下为DetailViewController类设置。
You can use the detailItem (id - so you can pass in a reference) property that is set up by default for the DetailViewController class.
这篇关于如何在使用splitViewController的iPad上引用detailViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!