Reputation: 35
I have an simple animation for changing background colors repeatedly on my UITableViewCell. Here is a snippet of my code. For some reason doing this will not all me to call my didSelectRowAtIndexPath method???? I know this because when I remove the code below, it works fine. Any solutions to this? Thanks!
-(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];
}
Upvotes: 1
Views: 235
Reputation: 8576
Add the UIViewKeyframeAnimationOptionAllowUserInteraction
option to your keyframe animation. I tested it, and this works for me:
-(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];
}
Upvotes: 2