Я пишу простое приложение для iOS и получаю сообщение об ошибке « UITableView dataSource должен вернуть ячейку из tableView: cellForRowAtIndexPath: »Я пытаюсь создать статическое содержимое строки.
My view controller
называется "StartViewController"
.В файле .xib у меня есть 3 UITableViewCell
objects
с именем "Section 0 Cell", "Section 1 Cell" and "Section 2 Cell"
.Они определены в файле .h как:
@interface StartViewController : UITableViewController
{
UITableViewCell *cell0;
UITableViewCell *cell1;
UITableViewCell *cell2;
}
@property (nonatomic, retain) IBOutlet UITableViewCell *cell0;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell1;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell2;
В файле .m они были синтезированы.Я не могу опубликовать фотографию моего создателя интерфейса, поскольку у меня еще нет репутации 10.
Ячейки заполнены так:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Processing section: %d, row: %d",[indexPath section], [indexPath row]);
if (cell0 == nil)
NSLog(@"cell0 is nil");
if (([indexPath section] == 0) && ([indexPath row] == 0))
return cell0;
if (([indexPath section] == 1) && ([indexPath row] == 0))
return cell1;
if (([indexPath section] == 2) && ([indexPath row] == 0))
return cell2;
return cell0;
}
Я знаю, что проблема в том, что ячейка 0 равна нулю, но я не могу понять, почему.