У меня есть UITableView, который имеет пять разделов. Так же, как заголовок описывает, cellForRowAtIndexPath вызывается только для первых четырех. Все соединения были сделаны относительно источника данных и делегата. Кроме того, мой numberOfSectionsInTableView явно возвращает 5. Распечатка количества разделов из cellForRowAtIndexPath показывает правильное число, подтверждая тем самым, что cellForRowAtIndexPath просто не вызывается для всех разделов. Что на земле происходит? Я довольно тяжело искал ответ на этот вопрос, но не смог его найти. Если это уже было дано, пожалуйста, прости меня и укажи мне правильное направление.
Моя ячейкаForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
switch (indexPath.section) {
case 0:
cell.textLabel.text = ticket.description;
break;
case 1:
cell.textLabel.text = ticket.ticketStatus;
break;
case 2:
cell.textLabel.text = ticket.priority;
break;
case 3:
cell.textLabel.text = ticket.customerOfficePhone;
break;
case 4: {
//This never ever gets executed
Comment *comment = [ticket.comments objectAtIndex:indexPath.row];
cell.textLabel.text = comment.commentContent;
break;
}
}
return cell;
}
Мой номер секции объявлений в таблице:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 5;
}
Мой номер раздела:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger numberOfRows;
if (section == 4) {
numberOfRows = [ticket.comments count];
}
else {
numberOfRows = 1;
}
return numberOfRows;
}
Любые предложения приветствуются. Заранее спасибо.