I want to have one custom cell (the first one) a different height to the others. I've done a few things to do this but every cell is the same height:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 150;
}
else {
return 60;
}
}
and
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier;
if (indexPath.row == 0) {
identifier = @"ProfilePictureCell";
}
else if (indexPath.row == 1) {
identifier = @"OtherCell";
}
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
I can't figure out why these aren't working.. Thanks!
EDIT: Here is the code for the cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier;
if (indexPath.row == 0) {
identifier = @"ProfilePictureCell";
}
else if (indexPath.row > 0) {
identifier = @"1";
}
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"ProfilePictureCell" owner:self options:nil];
cell = [nibArray objectAtIndex:0];
}
cell.imageView.image = [UIImage imageNamed:[self.foodImageArray objectAtIndex:indexPath.row]];
return cell;
}
This code displays the image in the first cell, which is great, but every other cell is the same size. Thanks