2014-09-19 1 views
1

У меня есть простая анимация для изменения цвета фона на моем UITableViewCell. Вот фрагмент моего кода. По какой-то причине делать это не будет, чтобы я мог вызвать мой метод didSelectRowAtIndexPath ???? Я знаю это, потому что, когда я удаляю код ниже, он работает нормально. Любые решения? Благодаря!Почему я не могу использовать UITableViewCell при анимации между двумя цветами фона ячейки?

-(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]; 
} 

ответ

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]; 
} 
+0

Это было! Большое спасибо! –

Смежные вопросы