当它在两个单元格背景颜色之间进行动画制作时,为什么我无法点击UITableViewCell?

时间:2014-09-19 03:06:12

标签: ios objective-c uitableview uianimation

我有一个简单的动画,用于在我的UITableViewCell上重复更改背景颜色。这是我的代码片段。出于某种原因这样做不会让我全部调用我的didSelectRowAtIndexPath方法????我知道这个,因为当我删除下面的代码时,它工作正常。对此有何解决方案?谢谢!

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell       forRowAtIndexPath:(NSIndexPath *)indexPath
{
[UIView animateKeyframesWithDuration:1.0 delay:0.0    options:UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat animations:^{
    [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.3 animations:^{
        cell.backgroundColor = [UIColor colorWithRed:3.0/255.0 green:165.0/255.0     blue:136.0/255.0 alpha:1.0];
        cell.detailTextLabel.textColor = [UIColor whiteColor];
        cell.textLabel.textColor = [UIColor whiteColor];
    }];
 } completion:nil];
} 

1 个答案:

答案 0 :(得分:2)

UIViewKeyframeAnimationOptionAllowUserInteraction选项添加到关键帧动画中。我测试了它,这对我有用:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    [UIView animateKeyframesWithDuration:1.0 delay:0.0 options:UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat | UIViewKeyframeAnimationOptionAllowUserInteraction animations:^{

         [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.3 animations:^{
            cell.backgroundColor = [UIColor colorWithRed:3.0/255.0 green:165.0/255.0 blue:136.0/255.0 alpha:1.0];
            cell.detailTextLabel.textColor = [UIColor whiteColor];
            cell.textLabel.textColor = [UIColor whiteColor];
        }];
    } completion:nil];
}