2009-05-27 67 views
1

我有这个非常奇怪的错误。当我向下滚动我的表格视图时,直到我称为“描述”的部分,本节中的单元格将不会显示。相反,该部分的标题会一再重复。这听起来像谁负责iPhone中的屏幕显示没有找到任何可显示的东西,并让屏幕上显示的内容(这是该部分的标题,因为我向下滚动)。设备中的奇怪错误:UITableView的单元格内容没有显示

如果我截取屏幕截图,那就是黑色背景,而不是单元格。

这个错误在模拟器中没有发生,但只在真实的设备中发生。

有没有人遇到过这样的事情?你能猜到问题在哪里吗?

回答

0

我找到了解决方案...很明显,但仍然...

我的UILabel的尺寸大于2048像素。我们不允许使用比这更大的尺寸,这就是渲染非常奇怪的原因。

这个线程stackoverflow.com/questions/773386/inserting-various-views-into-uiscrollview已经处理了这个问题。

0

尝试将单词描述更改为其他内容。 Objective C类使用单词描述来表示一个对象可以用NSString描述自己的方法。如果更改名称可以修复它,那么您的bug就是与此相关的。

你可以看到在工作描述是这样的:

NSString *aString = [[NSString alloc] initWithFormat:@"hi"]; 
NSLog(@"%@", [aString description]); 
+0

不错的猜测,我试过但没有改变任何东西... – Unfalkster 2009-05-27 14:45:00

0

谢谢您的回复,我会在这里把代码。但请记住,我的代码适用于所有其他单元格,因此它必须与此单元格的特定内容相关,但它只是UILabel中的一些文本...

请不要犹豫查看视频我已经说过,这对iPhone来说是一种非常好奇的行为,你甚至看到了吗? dl.free.fr/rlQmFyWS0

这里是的cellForRowAtIndexPath代码:方法,只是说明细胞有关的部分:

case 3: // A big cell containing the description 
    { 
     // Try to find an already allocated cell with the description (note : there is only one description cell per table so no need to check the content...) 
     UITableViewCell * descriptionCell = [tableView dequeueReusableCellWithIdentifier:kTextCellIdentifier]; 
     if (descriptionCell == nil) { 
      // As a frame, use the description label's one plus a little margin for the height 
      descriptionCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, self.descriptionText.frame.size.height + (2*kCellInset)) reuseIdentifier:kTextCellIdentifier] autorelease]; 
      descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone; 
      // The descriptionText UILabel has been previously initialized properly by tableview:heightForRowAtIndexpath: method 
      [descriptionCell.contentView addSubview:self.descriptionText]; 
     } 
     return descriptionCell; 

这里是我初始化descriptiontext描述场部分:

// Customize row height for each cell 
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
if (indexPath.section == 3) { 
    CGSize realSize; 
    if (self.descriptionText != nil) { 
     // the description has been previously initialized 
     realSize = descriptionText.frame.size; 
    } 
    else { 
     // We need to dynamically resolve the height for the description zone 
     NSString * desc = (NSString *)[product objectForKey:@"description"]; 
     UILabel * descLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 
     // Unlimited number of lines 
     descLabel.numberOfLines = 0; 
     descLabel.text = desc; 
     // Set a preferred width and anything for the height 
     realSize = [descLabel sizeThatFits:CGSizeMake(tableView.frame.size.width - (2*kCellInset), 1)]; 
     // Take the opportunity to set the frame with the correct values 
     descLabel.frame = CGRectMake(kCellInset, kCellInset, realSize.width, realSize.height); 
     self.descriptionText = descLabel; 
     [descLabel release]; 
    } 
    return (realSize.height + (2*kCellInset)); 
} 
else { 
    return kImageCellHeight; 
} 
return 0; 

}

任何猜测会更受欢迎......我一直在这里调查