Я создал прототип ячейки с идентификатором «mainViewTableCell» в файле раскадровки и соединил представление основной таблицы с пользовательским классом контроллера с именем «NTTableViewController». Я реализовал функцию tableView cellForRowAtIndexPath в NTTableViewController.m следующим образом:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* MAINVIEW_CELLIDENTIFIER = @"mainViewTableCell";
UITableViewCell *newCell = [tableView dequeueReusableCellWithIdentifier: MAINVIEW_CELLIDENTIFIER];
if (newCell == nil) {
newCell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: MAINVIEW_CELLIDENTIFIER];
[newCell autorelease];
newCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NTContactItem* currentItem = [self.contactItemContainer objectInContainerAtIndex: indexPath.row];
NSString* firstName = currentItem.firstName;
NSString* lastName = currentItem.lastName;
NSString* fullName = [firstName stringByAppendingFormat: lastName];
[newCell.textLabel setText: fullName];
[newCell.detailTextLabel setText: currentItem.mobilePhone];
return newCell;
}
Но я продолжаю получать nil из dequeueReusableCellWithIdentifier и каждый раз должен создавать новый экземпляр ячейки.
Тогда что не так?
Код : проект
Заранее всем спасибо.