0
我正在使用prepareForSegue和我的UISplitViewController
,我有一个NSMutableDictionary
填充UITableView
的部分。我所试图做的就是通过我的detailViewController
所选部分的方法选择的价值的价值,这是我走到这一步:Objective-C prepareForSegue问题
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSString *strPOIndex = [self.tableData[indexPath.row] valueForKey:@"Vendor"];
LHContactsDetail *controller = (LHContactsDetail *)[[segue destinationViewController] topViewController];
[controller setDetailItem:strPOIndex];
controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
controller.navigationItem.leftItemsSupplementBackButton = YES;
}
}
但这个问题,它返回的编号第一部分的项目。例如,如果我点击第2项第1项,它将返回第1项第1项,如果我点击第3项第2项,它将返回第1项第2项。我希望这是有道理的。这就是我如何填充我的tableview:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSString *sectionTitle = [contactSectionTitles objectAtIndex:indexPath.section];
NSArray *sectionContacts = [contactDirectoryFinal objectForKey:sectionTitle];
NSString *contacts = [[sectionContacts objectAtIndex:indexPath.row] valueForKey:@"Vendor_Name"];
cell.textLabel.text = contacts;
return cell;
}
我怎样才能得到正确的值发送给我的detailController
方法?
什么返回完全错误的值? 'indexPath'(来自'[self.tableView indexPathForSelectedRow]')还是'strPOIndex'? – Larme
strPOIndex .... indexPath是正确的,它只是总是在第一部分 – user979331
您使用'tableData',但那是什么?我建议你使用与'tableView:CellForRowAtIndexPath:'('sectionTitle','sectionContact')相同的mecanisme来获得你的价值。 – Larme