UIViewAnimationOptionAllowUserInteraction不工作

Syn*_*hro 2 uiviewanimation ios

我正在尝试UIImageView动画时检测到触摸.触摸检测在动画开始之前工作,一旦停止,但不会在期间停止.

我试过添加UIViewAnimationOptionAllowUserInteraction,但似乎根本没有效果!

有人能指出我正确的方向吗?

码:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];
    NSLog(@"tag=%@", [NSString stringWithFormat:@"%i", touch]);
    if ([touch view] == itemCoke)
    {
        NSLog(@"Coke Touched");
    }

}

- (IBAction)removeItemButton:(id)sender {
    NSLog(@"Pushed");


    [UIView animateWithDuration:5 
                          delay:0.0         
                        options:UIViewAnimationOptionAllowUserInteraction
                     animations:^
                             {
                                 itemCoke.transform = CGAffineTransformRotate(itemCoke.transform, (M_PI*-0.5));
                                 itemCoke.frame = CGRectMake(50, 50, 50, 50);
                             }
                     completion:^(BOOL finished){}];   
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的建议!

NJo*_*nes 9

交互不起作用的原因在于,基本上UIImageView不是它看起来的位置.只有视图的CALayer表示层在屏幕上进行动画处理.该视图已立即到达目的地.这使得交互更加困难.你可能会觉得这个答案很有帮助.