テーブルセルの特定のケースでは、画像がセルに追加されます。セルが正しく表示されません。これが私が意味することの写真です:
2番目のロックアイコンはそこに属していません...どのように、またはなぜそこにたどり着くのかわかりません。この例では、配列のカウントが 2 であるため、追加のロックはセル内にさえありません。
これは、最初のロードでは発生しませんが、セルが最初にリロードされるとすぐに発生します。初期ロード機能はリロード機能と同じであるため、これも混乱を招きます。
セル自体のコードは次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [UITableViewCell configureFlatCellWithColor:[UIColor greenSeaColor] selectedColor:[UIColor wetAsphaltColor] reuseIdentifier:CellIdentifier inTableView:(UITableView *)tableView];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[cell configureFlatCellWithColor:[UIColor greenSeaColor] selectedColor:[UIColor wetAsphaltColor]];
}
Room *room;
//is data filtered?
if(isFiltered)
room = [filteredTableData objectAtIndex:indexPath.row];
else
room = [roomList objectAtIndex:indexPath.row];
cell.textLabel.text = room.roomName;
cell.detailTextLabel.text = room.hostUsername;
//lock icon or not
if(room.password != nil)
{
UIImageView *pw = [[UIImageView alloc] initWithImage:img];
pw.tag = [room.rid integerValue];
[pw setImage:img];
pw.frame = CGRectMake(cell.frame.size.width - cell.frame.size.height, cell.frame.origin.y,
cell.frame.size.height - 2, cell.frame.size.height - 2);
[cell.contentView addSubview:pw];
}
else{ //remove the content view if not needed
[[cell.contentView viewWithTag:[room.rid integerValue]] removeFromSuperview];
}
return cell;
}
記録として、これは iOS7 では発生しません (NDA の下にあることは知っていますが、役立つ場合はその事実に言及したかっただけです)。