так вот мой код и он не работает
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier;
if (indexPath.row == 0)
{
// buttonCell
CellIdentifier = @"buttonCell";
buttonCell *cell = (buttonCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.startAddressLabel.text = @"something";
//cell config
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
NSLog(@"Cell Identifier: %@", CellIdentifier);
return cell;
} else if (indexPath.row == 1)
{
//mutableCaptionCell date&time
CellIdentifier = @"mutableCaptionCell";
mutableCaptionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//cell config
cell.infoLabel.text = @"Время и дата";
cell.contentLabel.text = @"";
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
return cell;
} else if (indexPath.row == 2)
{
//mutableCaptionCell tax
CellIdentifier = @"mutableCaptionCell";
mutableCaptionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//cell config
cell.infoLabel.text = @"Тариф";
cell.contentLabel.text = @"";
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
return cell;
} else if (indexPath.row == 3)
{
//mutableCaptionCell car
CellIdentifier = @"mutableCaptionCell";
mutableCaptionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//cell config
cell.infoLabel.text = @"Выбор машины на карте";
cell.contentLabel.text = @"";
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
return cell;
} else if (indexPath.row == 4)
{
//wishCell wishlist
CellIdentifier = @"wishCell";
WishCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//cell config
cell.infoLabel.text = @"Пожелания";
cell.contentLabel.text = @"";
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
return cell;
} else
{
//debug
NSLog(@"indexPath.row: %d", indexPath.row);
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mutableCaptionCell" forIndexPath:indexPath];
// Configure the cell...
cell.textLabel.text = @"ERROR CELL";
//debug
//NSLog(@"indexPath.row: %d", indexPath.row);
return cell;
;
}
}
Я сказал, что подклассы UITableViewCell для каждого прототипа, идентификаторы повторного использования соответствуют каждому прототипу, но то, что я вижу во время выполнения, похоже, что UITableView не использует эти прототипы. Например, первая ячейка должна быть огромной с двумя кнопками, а вместо этого отображается пустой. Я NSLoged все, и журнал показывает это:
2014-02-18 10:13:51.587 app[1624:70b] indexPath.row: 0
2014-02-18 10:13:51.590 app[1624:70b] Cell Identifier: buttonCell
2014-02-18 10:13:51.594 app[1624:70b] cell: <buttonCell: 0x8b95e00; baseClass = UITableViewCell; frame = (0 0; 320 44); autoresize = W; layer = <CALayer: 0x8b96000>>
2014-02-18 10:13:51.600 app[1624:70b] indexPath.row: 1
2014-02-18 10:13:51.603 app[1624:70b] indexPath.row: 2
2014-02-18 10:13:51.606 app[1624:70b] indexPath.row: 3
2014-02-18 10:13:51.610 app[1624:70b] indexPath.row: 4
но все же TableView не использует правильные прототипы.
Я пытаюсь использовать динамические прототипы, так как мне нужно изменить высоту некоторых ячеек во время выполнения, может быть, есть способ сделать это со статическими ячейками?
Примечание: я использую Xcode 5 для iOS 7