UITableViewCell问题。显示iOS 7和iOS 6的差异

时间:2013-09-26 15:23:32

标签: ios6 uitableview ios7 xib

这是我创建单元格的代码:

- (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;
}

我是从笔尖创建的:

enter image description here

但是iOS 7和iOS 6之间存在差异,请看下面的截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

我为单元格高度设置了值。默认情况下我没有使用这种方法导致我上面描述的问题。

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