我想显示在使用此代码我UITableViewCells的具体行的“挂锁”图标:的UITableView细胞accessoryView的形象问题
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCell"];
GPBTopic *topic = [self.topics.list objectAtIndex:indexPath.row];
cell.textLabel.text= topic.name;
if ((indexPath.row == 5) || (indexPath.row == 9))
{
cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"lock_icon.png"]];;
[cell.accessoryView setFrame:CGRectMake(0, 0, 24, 24)];
}
return cell;
}
我得到一个有趣的结果 - 挂锁最初显示的行5 ,但是当我向下滚动列表时,图标在其他单元的accessoryView上随机重新显示(只有1个部分btw),并且滚动变得相当生涩和迟缓...我向上/向下滚动它显示的实例越多! 为什么?这里的错误在哪里?
帮助,谢谢!
因为当你滚动单元已经重复使用其他行,我认为你应该使用不同的CellReuseIdentifier 5行和9 – 2013-03-11 22:56:22
我该怎么做呢? – mindbomb 2013-03-11 23:05:30