开发者

Iphone - Custom cell - can't set UILabel

开发者 https://www.devze.com 2023-03-06 02:04 出处:网络
I try to set my value in custom cell in a UITableView. But when I lauching it, there are no error but my value is not setted in the UILabel!

I try to set my value in custom cell in a UITableView. But when I lauching it, there are no error but my value is not setted in the UILabel!

and idea?

Custom cell:

@interface InscriptionCustomCell : UITableViewCell {

IBOutlet UILabel *titreCell;
IBOutlet UITextField *contenuCell;

}

View with my UITableView:

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

static NSString *CellIde开发者_运维知识库ntifier = @"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;

}


Like pratikshabhisikar said, connect the labels in the nib to the outlets in your class.

Then use UILabel.text property to set label text.

cell.yourCustomLabel.text = @"text";

or

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

Also please use the standard Apple terminology for your tags when you create questions. For example: ios,uikit etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号