UITableViewCell custom (перо)

Я сделал пользовательскую ячейку в NIB-файле с делегатом.

Я определил.h и.m для пользовательской ячейки:

@interface InscriptionCustomCell : UITableViewCell {

IBOutlet UILabel *titreCell;
IBOutlet UITextField *contenuCell;

}

@property (nonatomic, retain) UILabel * titreCell; @property (nonatomic, retain) UITextField * contenuCell;

@конец

И когда я пытаюсь использовать его с моим tableView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"InscriptionCustomCell";

InscriptionCustomCell *cell = (InscriptionCustomCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//[cell.textLabel setText:@"Cell"];
// Configure the cell...

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;

}

У меня ошибка:

reason: '-[UITableViewCell titreCell]: unrecognized selector sent to instance 0x4b5f430'

Зачем? Моя кастомная ячейка - это собственное утверждение!

2 ответа

Решение

Это не верно:

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

Вы создаете экземпляр UITableViewCell, а не свою пользовательскую ячейку.

if (cell == nil) {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyCell"owner:self options:nil];
    cell = [nib objectAtIndex:0];
}    
Другие вопросы по тегам