こんにちは、UITableViewがあり、画像を含むカスタム セルを使用しています。UITableViewをリロードすると、問題なくリロードされますが、画像は削除されません。これを画像に nil に設定し、removeFromSuperView も試してみましたが、うまくいきませんでした。
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:identity];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identity DefaultsArray:defaultColAndSpacesDict];
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
if([[dtaDictionary allKeys] count]!=0)
{
[cell.contentView clearsContextBeforeDrawing];
if([defaultsArray containsObject:@"Note"])
{
NSString *patNotes=[[currRow objectForKey:@"pat_notes"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *appNotes=[[currRow objectForKey:@"Notes"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if((![patNotes isEqualToString:@""] && patNotes!=nil) || (![appNotes isEqualToString:@""] && appNotes!=nil))
{
[cell.Note setBackgroundImage:[UIImage imageNamed:@"notes-green.png"] forState:UIControlStateNormal];
[cell.Note setBackgroundImage:[UIImage imageNamed:@"notes-green.png"] forState:UIControlStateHighlighted];
[cell.Note addTarget:self action:@selector(showNote:) forControlEvents:UIControlEventTouchUpInside];
}
else
{
cell.Note.imageView.image=nil;
}
}
プログラムをデバッグしましたが、nil が割り当てられています。私もImageViewのremoveFromSuperViewを試しました。何が問題なのですか?
注: Cell.Note は UIButton です