我在iPhone模拟器上的导航控制器中有一个非常奇怪的问题与UITableview。在显示的单元格中,只有一些单元被正确渲染。他们都应该看起来一样,但大多数都缺少我设置的附件,滚动视图变化的细胞有附件,所以我怀疑它是某种细胞缓存发生,虽然内容是正确的每个细胞。我还设置一个图像作为背景,并且也仅显示零星但我固定,通过改变UITableview呈现问题
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yellow-bar_short.png"]];
(其也仅呈现与背景的随机小区)
cell.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"yellow-bar_short.png"]];
我现在需要使用仅在随机单元上显示的附件来解决问题。我尝试将代码从cellForRowAtIndex移动到willDisplayCell,但它没有任何区别。我输入一个日志命令来确认它正在每个帧中运行。
基本上它是一个表格视图(UITableViewCellStyleSubtitle),它从服务器&获取其信息,然后通过调用reload的委托方法进行更新。代码是:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%@", [NSString stringWithFormat:@"Setting colours for cell %i", indexPath.row]);
// Set cell background
// cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yellow-bar_short.png"]];
cell.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"yellow-bar_short.png"]];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
// detailTableViewAccessory is a view containing an imageview in this view's nib
// i.e. nib <- view <- imageview <- image
cell.accessoryView = detailTableViewAccessory;
}
// Called by data fetching object when done
-(void)listDataTransferComplete:(ArticleListParser *)articleListParserObject
{
NSLog(@"Data parsed, reloading detail table");
self.currentTotalResultPages = (((articleListParserObject.currentArticleCount - 1)/10) + 1);
self.detailTableDataSource = [articleListParserObject.returnedArray copy]; // make a local copy of the returned array
// Render table again with returned array data (neither of these 2 fixed it)
[self.detailTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
// [self.detailTableView reloadData];
// Re-enable necessary buttons (including table cells)
letUserSelectRow = TRUE;
[btnByName setEnabled:TRUE];
[btnByPrice setEnabled:TRUE];
// Remove please wait message
NSLog(@"Removing please wait view");
[pleaseWaitViewControllerObject.view removeFromSuperview];
}
我只包含我认为相关的代码,如果需要可以提供更多代码。我无法在iPhone上测试它,所以我不知道它可能只是一个模拟器异常或我的代码中的错误。我一直从问题,任何想法得到很好的反馈?