Search code examples
ios6uitableviewios7xib

UITableViewCell issue. Differences in displaying iOS 7 and iOS 6


This is my code how I create cell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifier = @"cellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (!cell)
    {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] lastObject];
    }

    UIImageView * imageView = (UIImageView *)[cell viewWithTag:1];

    imageView.image = [UIImage imageNamed:@"nature.jpg"];

    UILabel *nameLabel = (UILabel *)[cell viewWithTag:2];
    nameLabel.text = @"Some text";

    UILabel *priceLabel = (UILabel*)[cell viewWithTag:3];
    priceLabel.text = [_prices objectAtIndex:indexPath.row];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
}

I create it from the nib:

enter image description here

But there are differences between iOS 7 and iOS 6 take a look on screenshots below:

enter image description here


Solution

  • I have set value for the cell height. By the default I have not use this method it cause to the issue that I described above.

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 65.0f;
    }