小编And*_*ner的帖子

自定义UITableViewCell不会在setNeedsDisplay上重绘

我创建了一个UITableViewCell带有a UIButton,a UIImage和two 的自定义类UILabels.按钮和图像叠加在一起,一次只显示一个.预期的行为是您触摸按钮,按钮消失,并显示图像.该UITableViewCells设置可以重复使用.这是我的代码:

构造函数:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        unheartButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];

        unheartButton.backgroundColor = [UIColor clearColor];
        unheartButton.frame = CGRectMake(10, 13, 20, 18);

        [unheartButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside];   
        [unheartButton setBackgroundImage:[UIImage imageNamed:@"redheart.png"] forState:UIControlStateNormal];

        imageView = [[UIImageView alloc] init];
        imageView.frame = CGRectMake(12, 13, 16, 16);

        NSMutableArray *array = [[NSMutableArray alloc] init];

        for (int ndx = 1; ndx < 13; ndx++) {
            [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"icon-loading-%d (dragged).tiff", …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c iphone-sdk-3.0

5
推荐指数
1
解决办法
6776
查看次数

标签 统计

cocoa-touch ×1

iphone ×1

iphone-sdk-3.0 ×1

objective-c ×1