Iphone 主细节应用程序
我已经设法将一些值读入表视图,并在SplitViewController的主视图中显示它们 我想做的是点击主视图的一行,并在detailViewController上显示详细信息,但显示在TableView的自定义单元格中,该单元格有一个标签和一个文本字段 当我点击MasterView表中的行时,我似乎无法获取用于填充detailview自定义单元格的详细信息 我试过类似的东西Iphone 主细节应用程序,iphone,objective-c,ios,xcode,ipad,Iphone,Objective C,Ios,Xcode,Ipad,我已经设法将一些值读入表视图,并在SplitViewController的主视图中显示它们 我想做的是点击主视图的一行,并在detailViewController上显示详细信息,但显示在TableView的自定义单元格中,该单元格有一个标签和一个文本字段 当我点击MasterView表中的行时,我似乎无法获取用于填充detailview自定义单元格的详细信息 我试过类似的东西 if (indexPath.row == 0) { lbPerson.text = @"Name";
if (indexPath.row == 0) {
lbPerson.text = @"Name";
tfPerson.text = @"John";
tfPaciente.placeholder = @"Name";
}else if (indexPath.row == 1) {
lbPerson.text = @"Address";
tfPerson.text = @"Street blabla";
tfPerson.placeholder = @"Address";
}
但当我点击masterview表时,我不确定将代码放在何处以及如何更新我的detailview tableview
谢谢大家! 在detailView中,您应该有“id detailItem”,然后在委托方法中设置: -(void)setDetailItem:(id)newDetailItem{
if (_detailItem != newDetailItem) {
_detailItem = [newDetailItem retain];
// Update the view.
[self configureView];
}
}
-(无效)配置视图{
// Update the user interface for the detail item.
if (self.detailItem) {
//do something ... reload tableview or change values etc
}
}
要在MasterView中调用此方法,请执行以下操作:
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath{
self.YOURDETAILVIEWCONTROLLER.detailItem = @"Example";
self.YOURDETAILVIEWCONTROLLER.title = [NSString stringWithFormat:@"You Pressed Row %d", indexPath.row];
}
这将调用设置细节视图的第一个方法,显然,通过这个细节项可以设置细节视图的属性