我有一个简单的动画,用于在我的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];
}
答案 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];
}