2013-09-26 37 views
0

差異這是我的代碼如何創建單元:UITableViewCell問題。在顯示的iOS 7和iOS 6

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

+0

我也有多個單元格顯示在iOS 6和iOS 7上的問題。不知道如何解決它們。也許蘋果會做一些事情來解決這些問題。分組表在iOS 7中也顯示爲不同。有人找到了解決方法? –

+0

@benyboariu你解決了你的問題嗎? –

+0

不,還沒解決。 –

回答

0

我已經爲單元格高度設置了值。默認情況下,我沒有使用這種方法,它導致了我上面描述的問題。

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