如何在单行中加载两个记录?

时间:2012-09-12 05:08:25

标签: iphone objective-c uitableview

可以在tableview中的一行中加载两条记录吗?

3 个答案:

答案 0 :(得分:3)

可以使用descriptionlabel.text将另一个标签显示为

cellobj.textLabel.text=[arr1 objectAtIndex:indexPath.row];
cellobj.descriptionLabel.text=[arr2 objectAtIndex:indexPath.row];

答案 1 :(得分:1)

您必须在UITableViewCell中创建自己的UILabel元素。您可以将新的UILabel添加到您的单元格中(我认为您应该添加它们的内容视图,或者您可以创建UITableViewCell的子类并让它为您创建标签并使用标签提供对它们的访问。

答案 2 :(得分:1)

使用带字幕样式的UITableViewCell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } //did the subtitle style

        NSUInteger row = [indexPath row];
        cell.textLabel.text = record1;
        cell.detailTextLabel.text = record2;
    }
    return cell;
}