2013-02-28 74 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)