Я пытаюсь отчаянно выяснить, как я могу настроить настройку ячейки стиля Tableview, зависящей от значения в словаре. Словарь - это строка SQLite, и я установил столбец, чтобы установить, какую ячейку использовать (столбец «Тип»). Затем следует указать cellForRowAtIndexPath, какой стиль ячейки использовать. На мой взгляд, этот код должен работать без проблем, но я постоянно получаю следующее сообщение об ошибке:Ячейка стиля Tableview зависит от значения в словаре
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Любая помощь будет здорово! большое спасибо, Andrew
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
dictionary = [tableDataSource objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if ([dictionary objectForKey:@"Type"] == @"1") {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;
cell.detailTextLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
}
else if ([dictionary objectForKey:@"Type"] == @"0") {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:12.0];
}
}
// Configure the cell...
cell.textLabel.text = [dictionary objectForKey:@"Title"];
cell.detailTextLabel.text = [dictionary objectForKey:@"Right_Info"];
return cell; }