so here is my code and it doesn't work
- (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;
;
}
}
I have said subclasses of UITableViewCell for each prototype, the reuse identifiers match each prototype, but what I see on runtime looks like the UITableView doesn't use these prototypes. For example, first cell must be huge one with two buttons, but instead it is shown empty. I NSLoged everything, and log show this:
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
but still TableView doesn't use correct prototypes.
I'm trying to use dynamic prototypes as I need to change some cells height at runtime, may be there is a way to do so with static cells ?
Sidenote: Im using Xcode 5 for iOS 7