【问题标题】:Populating a tableViewCell left Detail向左填充一个 tableViewCell 详细信息
【发布时间】:2013-02-28 23:37:08
【问题描述】:

您能帮我填充左侧的详细信息单元格吗?

我需要的是使用核心数据中的属性键作为左侧细节,属性的内容作为标题。

我已将一个对象提取到一个数组中,我需要帮助在单元格上显示数据

 if (matchingData.count <= 0)
{
    cell.textLabel.text = @"no item found";
}
else {
    NSString *displayData;
    for (NSManagedObject *obj in matchingData) {
        displayData = [obj valueForKey:@"Name"];
        cell.detailTextLabel.text = displayData;
        cell.textLabel.text = @"Name";

      }
   }

我需要做什么才能让表格视图像苹果联系人应用程序一样显示?

【问题讨论】:

标签: iphone ios tableview


【解决方案1】:

为了能够使用 detailTextLabel,您需要使用 UITableViewCellStyleSubtitle 类型初始化单元格,如下所示:

static NSString *MyCellIdentifier = @"AUniqueIdentifier";

    UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];

    if (!cell) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MKCellIdentifier];
    }

我还会检查 displayData 是否为 nil 或空屏幕,例如 if (displayData.length &gt; 0)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-09
    • 2013-04-09
    • 2021-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多