サブクラス化された UITableViewCell があり、正常に動作しています。選択すると、カスタムのセルの色とテキストの色があり、他のセルが選択されるまで選択されたままになります。
問題は、このセルに UIImageView があることです。セルが選択されていない場合は表示されますが、セルが選択されている場合は UIImageView が消えます。
これは私のコードです、
#import "MMSideDrawerTableViewCell.h"
@implementation MMSideDrawerTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds];
[backgroundView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[backgroundView setBackgroundColor:[UIColor colorWithRed:77.0/255.0
green:79.0/255.0
blue:80.0/255.0
alpha:1.0]];
[self setBackgroundView:backgroundView];
UIView *sa = [[UIView alloc]initWithFrame:CGRectMake(180, 4, 20, 20)];
sa.backgroundColor = [UIColor greenColor];
[self.contentView addSubview:sa];
[self.textLabel setTextColor:[UIColor
colorWithRed:230.0/255.0
green:236.0/255.0
blue:242.0/255.0
alpha:1.0]];
[self.textLabel setShadowColor:[[UIColor blackColor] colorWithAlphaComponent:.5]];
[self.textLabel setShadowOffset:CGSizeMake(0, 1)];
[self.textLabel setFont:[UIFont boldSystemFontOfSize:16.0]];
//highlited
UIImageView *selectionColor = [[UIImageView alloc] init];
selectionColor.backgroundColor = [UIColor blackColor];
self.selectedBackgroundView = selectionColor;
self.textLabel.highlightedTextColor = [UIColor colorWithRed:49/255.0f green:101/255.0f blue:135/255.0f alpha:1];
}
return self;
}
@end
何が問題ですか?選択したセルで画像を表示するにはどうすればよいですか?
編集、背景の選択状態の行にコメントを付けると、アイコン uiImageView が非表示になります
//self.selectedBackgroundView = selectionColor;
ありがとう!