3

I am creating buttons programatically, and they are animated (fade & movement), I need the buttons to still have user interaction though. I have tried things like

options:(UIViewAnimationOptionAllowUserInteraction

which seems to do nothing :/ I have read several posts on here with different advice, including someone saying it isn't actually possible. Does anyone know if I can enable user interaction while a button is animating, and if it's not possible how do people get around this issue?

Thank you.

This is the current animation code that I was using:

[UIView animateWithDuration:106 
                      delay:0 
                    options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionCurveEaseInOut)
                 animations:^{


                     [_planetButton setCenter:point];
                     _planetButton.alpha = 0.2;
                     _planetButton.userInteractionEnabled = YES;


                 }
                 completion:^(BOOL finished){
                     NSLog(@"animation completed");
                     //[_planetButton removeFromSuperview];
                 }
 ];

I also tried animation such as:

    CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"transform2"]; 
    move.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    move.duration = 5.105;
    move.repeatCount = 1;
    move.autoreverses = YES;
    move.removedOnCompletion = YES;
    move.toValue = [NSValue valueWithCGPoint:point];
    [_planetButton.layer addAnimation:move forKey:nil];
cmoz
  • 31
  • 3
  • how do you animate the button? – Chakalaka Jul 18 '12 at 10:20
  • could you send us the whole block and the definition of the animation? – holex Jul 18 '12 at 10:22
  • thanks, added the different code blocks I was trying. – cmoz Jul 18 '12 at 10:29
  • Silly question: Does the interaction work without the animation? – jbat100 Jul 18 '12 at 10:36
  • Yes, I've tried different types of animation blocks and they all work - just I can't click the button which is needed for the app :/ – cmoz Jul 18 '12 at 10:41
  • can you add how you are creating the button? – mootymoots Jul 18 '12 at 11:02
  • Ok - it seems like the clickable area is actually located already at my final animation destination (point) so if I click there, it does select / activate while it's animating, but clearly that's a problem as no one would know to click a button in a different location. – cmoz Jul 18 '12 at 12:00
  • It's been a while since this was asked, but since there wasn't a solution and I came across one, thought that I would link in a result that worked for me: http://stackoverflow.com/questions/8346100/uibutton-cant-be-touched-while-animated-with-uiview-animatewithduration. – David Hunt Oct 12 '12 at 19:18

0 Answers0