Iphone 设备中的奇怪错误:UITableView';s单元格内容未显示
我有一只很奇怪的虫子。当我向下滚动表格视图,向下滚动到我称为“描述”的部分时,该部分中的单元格将不会显示。取而代之的是,这一节的标题被一次又一次地重复。听起来,无论是谁负责iPhone的屏幕显示,他都找不到任何可以显示的东西,并让屏幕显示以前的内容(这是本节的标题,因为我向下滚动了) 如果我拍一张截图,只有一个黑色背景而不是单元格 这个错误不是在模拟器中发生的,而是在真实设备中发生的Iphone 设备中的奇怪错误:UITableView';s单元格内容未显示,iphone,uitableview,Iphone,Uitableview,我有一只很奇怪的虫子。当我向下滚动表格视图,向下滚动到我称为“描述”的部分时,该部分中的单元格将不会显示。取而代之的是,这一节的标题被一次又一次地重复。听起来,无论是谁负责iPhone的屏幕显示,他都找不到任何可以显示的东西,并让屏幕显示以前的内容(这是本节的标题,因为我向下滚动了) 如果我拍一张截图,只有一个黑色背景而不是单元格 这个错误不是在模拟器中发生的,而是在真实设备中发生的 有人见过这种事吗?你能猜出问题出在哪里吗?试着把这个词的描述改成别的词。Objective C类使用单词desc
有人见过这种事吗?你能猜出问题出在哪里吗?试着把这个词的描述改成别的词。Objective C类使用单词description来表示一种方法,其中一个对象可以使用NSString来描述自己。如果更改名称可以修复它,那么您的bug就是与此相关的 您可以看到这样的工作描述:
NSString *aString = [[NSString alloc] initWithFormat:@"hi"];
NSLog(@"%@", [aString description]);
谢谢你的回复,我会把代码放在这里。但请记住,我的代码适用于所有其他单元格,因此它必须与此单元格的特定内容相关,但它只是UILabel中的一些文本 请毫不犹豫地查看我制作的视频,这对iPhone来说是一种非常奇怪的行为,你看到了吗?dl.free.fr/rlQmFyWS0 下面是cellForRowAtIndexPath:method的代码,只是描述单元格所涉及的部分:
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;
}
任何猜测都是非常受欢迎的。。。我一直在这里调查我找到了解决办法。。。这是显而易见的,但仍然 我的UILabel的大小大于2048 px。我们不允许使用大于该值的大小,这就是渲染如此怪异的原因 此线程stackoverflow.com/questions/773386/inserting-variable-views-into-uiscrollview已经处理了该问题。节头“Description”不应引起任何问题。这是一个普通的字符串!