【发布时间】:2012-03-12 17:55:40
【问题描述】:
我正在处理一个要求,我需要一个 TableView 有两列,它们不应该相互独立。因此,我不是在寻找两个独立滚动的 TableView,而是在寻找两个可以一起滚动的列的单个 TableView。在每一列中,我再次需要填写数据和屏幕截图。
到目前为止,我已经修改了 cellForRowAtIndexPath 中的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
static NSString *secondCellIdentifier = @"Cell2";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:secondCellIdentifier];
if (cell2 == nil) {
cell2 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:secondCellIdentifier] autorelease];
}
// Configure the cell...
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text = [tableList objectAtIndex:indexPath.row];
cell2.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell2.textLabel.text = [tableList2 objectAtIndex:indexPath.row];
UITableViewCell *twoColumnRowView = [[UITableViewCell alloc]init];
[twoColumnRowView addSubview:cell];
[twoColumnRowView addSubview:cell2];
return twoColumnRowView;
}
但不幸的是,我没有得到一个两列的表格,而是得到了一个奇怪的输出,可以在屏幕截图中看到。
谁能指引我正确的方向。
附:我在同一个论坛和互联网上浏览过关于同一主题的先前帖子,但没有任何适当的解释或示例。最好能得到有用的信息。
谢谢
【问题讨论】:
标签: objective-c ipad ios5 xcode4.2