I want to move a UIButton with animation, and while its moving if user touches it, I want recognized that event, but during animation UIButton doesn't sent any event.
Please solve my problem.
I want to move a UIButton with animation, and while its moving if user touches it, I want recognized that event, but during animation UIButton doesn't sent any event.
Please solve my problem.
Have you tried AllowUserInteraction option?
[UIView animateWithDuration:5.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{ // move the button }
completion:^(BOOL finished){}];
During an animation, user interactions are temporarily disabled for all views involved in the animation, regardless of the value in this property. You can disable this behavior by specifying the UIViewAnimationOptionAllowUserInteraction option when configuring the animation.
Also, you can implement
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
in the superview to catch the event and see if the event is pointing to the button.
As UIButton
inherit from UIControl
which inherit UIView
, I believe you are using the block based method to animate your button animateWithDuration:delay:options:animations:completion:
You will need to add the option UIViewAnimationOptionAllowUserInteraction
when you animate your UIButton to allow to recognize some user interaction. As you experimented user interaction are by default disabled during the animation otherwise.