【发布时间】:2015-07-16 01:47:41
【问题描述】:
我在显示选定单元格的详细信息时遇到了问题。但是这个单元格是在一个TableView 水平的,而这个TableView 是在另一个TableViewController 的一个单元格中。我希望你能理解我。
这里是 TableViewController(命名为 HostingTableViewController)的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellWithTableInside";
CellWithTableInside *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CellWithTableInside alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.backgroundColor = [UIColor blackColor];
NSArray *tabSection = [dictionarySection keysSortedByValueUsingComparator:^NSComparisonResult(id obj1, id obj2){
return [obj1 compare:obj2];
}];
NSArray* sortedNumbers = [tabSection sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
if ([obj1 integerValue] > [obj2 integerValue]) {
return (NSComparisonResult)NSOrderedDescending;
}
if ([obj1 integerValue] < [obj2 integerValue]) {
return (NSComparisonResult)NSOrderedAscending;
}
return (NSComparisonResult)NSOrderedSame;
}];
id key,value;
key = [sortedNumbers objectAtIndex: [indexPath section]];
value = [dictionarySection objectForKey: key];
[cell setCellData:[dictionaryClip objectForKey:key]];
return cell;
}
这里是用于显示细节控制器的 Cell 代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailClip *secondVC = [[DetailClip alloc]initWithClip:[array objectAtIndex:[indexPath row]]];
[pushVC.navigationController pushViewController:secondVC animated:YES];
}
pushVC 在这里初始化:
pushVC = [[HostingTableViewController alloc]init];
如果您需要更多信息或代码,请告诉我。
提前致谢:)
【问题讨论】:
标签: ios objective-c uitableview detailsview horizontallist