我想顯示在使用此代碼我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