2011-05-16 67 views
0

我尝试在UITableView的自定义单元格中设置我的值。但是,当我开发它时,没有错误,但是我的价值没有设置在UILabel中!Iphone - 自定义单元格 - 无法设置UILabel

和想法?

自定义单元格:

@interface InscriptionCustomCell : UITableViewCell { 

IBOutlet UILabel *titreCell; 
IBOutlet UITextField *contenuCell; 

}

查看我的UITableView:

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"InscriptionCustomCell"; 

InscriptionCustomCell *cell = (InscriptionCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"InscriptionCustomCell" owner:self options:nil]; 

    for (id currentObject in topLevelObjects){ 
     if ([currentObject isKindOfClass:[UITableViewCell class]]){ 
      cell = (InscriptionCustomCell *) currentObject; 
      break; 
     } 
    } 
} 
cell.selectionStyle = UITableViewCellSelectionStyleNone; 

if(indexPath.section == 0) 
{ 
    [cell.titreCell setText:[model.listModuleInfoPerso objectAtIndex:indexPath.row]]; 
    [cell.contenuCell setPlaceholder:[model.listModuleInfoPerso objectAtIndex:indexPath.row]]; 
}else { 
    [cell.titreCell setText:[model.listModuleInfoSupp objectAtIndex:indexPath.row]]; 
    [cell.contenuCell setPlaceholder:[model.listModuleInfoSupp objectAtIndex:indexPath.row]]; 
} 
return cell; 

}

+0

为什么会有休息;? – 2011-05-16 17:04:25

+1

确保标签在您的笔尖上连接到适当的插座 – 2011-05-16 17:24:29

回答

0

像pratikshabhisikar说,在笔尖连接标签的网点你的班。

然后使用UILabel.text属性来设置标签文本。

cell.yourCustomLabel.text = @"text"; 

NSString * labelText = [something...]; 
cell.yourCustomLabel.text = labelText; 

此外,当您创建问题,请使用您的标签标准的苹果术语。例如:ios,uikit等。

+1

我在我的博客上发布了一篇关于使用自定义单元格的帖子,可能它对您有用http://effectivemobility.blogspot.com/2011/05/using -custom细胞,在你的uitableview.html – arclight 2011-05-24 23:56:18

相关问题