Tag: reuseidentifier

UITableViewCell可重用性问题。 修改一个单元格正在影响他人

每当select第3节的单元格时。 我正在更新DataSource数组,并且单元格的背景颜色因此正确地更改。 然而,每当我滚动回来,我开始看到具有修改背景颜色的随机单元格,知道我甚至没有在我的cellForRowAtIndexPath方法中提及它,并且我的tableView每个部分都从单独的数据源Array/Dictionary填充! (我使用Storyboard来处理所有UI设置) 这是我的代码(关注第3节) – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ECTextFieldTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kSettingsTextFieldCellReuseIdentifier forIndexPath:indexPath]; if (indexPath.section == 0) { cell.cellTextField.text = [self.personalInfoDataSource valueForKey:kUserValuesKey][indexPath.row]; } else if (indexPath.section == 1) { cell.cellTextField.text = [self.contactInfoDataSource valueForKey:kUserValuesKey][indexPath.row]; } else if (indexPath.section == 2) { cell.cellTextField.text = [self.professionalDetailsDataSource valueForKey:kUserValuesKey][indexPath.row]; } else if (indexPath.section == 3) […]

iOS:当滚动太快时,UITableView混合数据

我已经分类了UITableViewCell添加自定义外观。 在MYTableViewCell的init级别,我添加了4个子视图:UIImageView和三个UILabel(s)。 所有4个子视图都分配了不同的标签。 在cellForRowAtIndexPath方法里面,我要么创build一个新的单元格,如果它不是最初可用的,或者重用可用的单元格并将正确的文本分配给UI标签。 我遇到的问题是,如果我试图超快滚动,然后数据会搞砸,但是如果我更慢地上下滚动,那么一切正常。 有什么想法吗?? 以下是代码: – (MyTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"itemListTableViewCell"; MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; DisplayableEntity *displayableEntity = [self.fetchedResultsController objectAtIndexPath:indexPath]; if( ! cell ) { cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; [self tableView:tableView appearanceForCell:cell withEntity:displayableEntity]; } else { UIImageView *imageView = (UIImageView *) [cell viewWithTag:IMAGEVIEW_TAG]; imageView.image […]

UITableView和单元重用

我有一个UITableView和我已经分类UITableViewCell (称为CustomCell ),所以它有几个标签和一个UIImageView 。 只有特定的单元格才会显示图像。 这是我的代码为tableView:cellForRowAtIndexPath: :: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Match *aMatch = [[appDelegate.matchByDate objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } cell.homeLabel.text = aMatch.homeTeam; cell.awayLabel.text = aMatch.awayTeam; cell.timeLabel.text = aMatch.koTime; cell.tournamentLabel.text = […]

UITableView分隔符通过单元重用绘制不正确?

我正在与故事板一起工作iOS 5项目,因此在IB中使用dynamic表格单元格原型。 在其中的一个意见,我有一个可变高度单元格的表格视图,单元格的高度从内容的高度计算。 tableView:heightForRowAtIndexPath:当第一次显示表视图时,返回所有单元格的正确值。 所有这一切都很好,当滚动几个项目,但然后有什么不对劲:实际单元格似乎是正确的高度,包括他们的触摸区域,但他们的分隔符被渲染在错误的地方(单元格之间,而不是他们之间)。 从测量分隔符的位置来看,似乎电池再利用可能与此有关。 前三个单元格的分隔符被正确渲染,但不是第四个。 heightForRowAtIndexPath:返回正确的高度(在这种情况下为125像素),其包含的子视图都在正确的位置。 但是,分隔符仅从前一个分隔符呈现108像素,将其放置在单元格的125像素高区域内。 这里是踢球者:108px是第一个表格单元格的高度,现在看不见了,可能重用。 我没有这方面的明确证据,但似乎表视图忽略heightForRowAtIndexPath:对于这些单元格,只是根据重用的单元格高度来呈现分隔符。 这并不能解释为什么一堆后来更短的单元格根本就没有渲染分隔符。 但这是我必须继续。 是否有解决方法,IB设置或其他可能的帮助?

如何清除caching的UITableViewCell

有没有人有关于如何清除caching的UITableViewCell ? 我想用reuseIdentifiercaching这些单元格。 不过,有时候我需要删除或修改一些表格行。 我希望行更改后调用reloadData 。 现在, dequeueReusableCellWithIdentifier总是返回之前的caching(过时)条目。 如何指示caching已过时并需要清除?