UITableViewCell custom (перо) - PullRequest
       4

UITableViewCell custom (перо)

0 голосов
/ 08 мая 2011

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

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

@interface InscriptionCustomCell : UITableViewCell {

IBOutlet UILabel *titreCell;
IBOutlet UITextField *contenuCell;

}

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

@ end

И когда я пытаюсь использовать его с моим 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 ]

1 голос
/ 28 марта 2013
if (cell == nil) {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyCell"owner:self options:nil];
    cell = [nib objectAtIndex:0];
}    
1 голос
/ 08 мая 2011

Это неправильно:

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

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...