2013-02-28 71 views
0

您能否帮我填充左侧的细节单元格?填充tableViewCell left详细信息

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

我已经赚得了一个对象到一个数组,我需要帮助的细胞

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"; 

     } 
    } 

我需要什么,以获得显示,就像苹果的联系人应用程序中的表视图做显示的数据?

+0

您是否将uCableViewCellStyleSubtitle的tableview单元格样式初始化?检查此http://stackoverflow.com/questions/2349279/cell-detailtextlabel-text-not-working-why – HRM 2013-02-28 15:33:09

回答

0

为了能够使用detailTextLabel你需要UITableViewCellStyleSubtitle类型来初始化你的是这样的:

static NSString *MyCellIdentifier = @"AUniqueIdentifier"; 

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

    if (!cell) { 

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

我还要检查displayData不是零或空白的屏幕,这样if(displayData.length > 0)