如何在选择uitableviewcell时使子视图不闪烁

时间:2015-01-25 05:16:48

标签: uitableview animation subview iso

这是tableview单元格

#import "ChannelCell.h"

@implementation ChannelCell
#pragma wipe the white space on the left
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    [self.detailView setBackgroundColor:[UIColor clearColor ]];// 127 green:127 blue:127 alpha:0.7]];
    [self setHighlighted:FALSE];
}
@end
tableviewconrtroller中的

,添加detailView:

 UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(cell.detailView.frame.size.height/2, cell.detailView.frame.size.height/2, cell.detailView.bounds.size.width/5*2, 1)];
    cell.detailView.alpha = 0.7;
    //[cell.detailView setBackgroundColor:[UIColor colorWithRed: 127 green:127 blue:127 alpha:0.7]];
    [cell.detailView setUserInteractionEnabled:NO];
    lineView.backgroundColor = [UIColor whiteColor];
    lineView.alpha = 0.5;
    //clock image
    //UIImageView *clockImageView =  [[UIImageView alloc] initWithFrame:CGRectMake(self.detailView.frame.size.width-self.detailView.frame.size.height,self.detailView.frame.size.height/4,  self.detailView.bounds.size.height/2, self.detailView.bounds.size.height/2)];
    UIButton *clockButton = [[UIButton alloc] initWithFrame:CGRectMake(cell.detailView.frame.size.width-cell.detailView.frame.size.height,cell.detailView.frame.size.height/3,  cell.detailView.frame.size.height/3, cell.detailView.frame.size.height/3)];
    [clockButton setImage:[UIImage imageNamed:@"clock@2x.png"] forState: UIControlStateNormal];
    clockButton.alpha = 0.3;
    [clockButton setUserInteractionEnabled:YES];
    //tv program name
    UILabel* programNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(cell.detailView.frame.size.height/2, cell.detailView.frame.size.height/3, cell.detailView.frame.size.width/5*1, cell.detailView.frame.size.height/2)];
    programNameLabel.alpha = 0.5;
    programNameLabel.text=@"TEST";
    [programNameLabel setUserInteractionEnabled:NO];

    [cell.detailView addSubview:programNameLabel];
    [cell.detailView addSubview:clockButton];
    [cell.detailView addSubview:lineView];
    [cell setHighlighted:NO];

这里是didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"cell selected at index path %ld:%ld", (long)indexPath.section, (long)indexPath.row);

     if (!tableView.isEditing) {
        [tableView deselectRowAtIndexPath:indexPath animated:NO];
    }
}

eveytime当我点击单元格时,子视图flash.i只是希望子视图保持静止,所以[tableView deselectRowAtIndexPath:indexPath animated:NO];但似乎没有工作。子视图消失了很短的时间,然后再次出现,只是一瞬间。我怎么能删除这个闪光灯

0 个答案:

没有答案