我正在使用CABasic
動畫來移動UIImageView
。 UIImageView
現在沒有檢測到觸摸動畫完成後如何啓用用戶交互?如何在動畫完成的圖像視圖中啓用交互
[ImageView setUserInteractionEnabled:NO];
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=1;
theAnimation.repeatCount=1;
theAnimation.autoreverses=NO;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:self.view.frame.size.width/2];
theAnimation.removedOnCompletion = NO;
theAnimation.fillMode = kCAFillModeForwards;
[CATransaction setCompletionBlock:^{
NSLog(@"finished");
self.view.userInteractionEnabled = true;
}];
[ImageView.layer addAnimation:theAnimation forKey:@"slide"];
[CATransaction commit];
你設置''[ImageView setUserInteractionEnabled:否];''但'self.view.userInteractionEnabled = true';你應該嘗試'[ImageView setUserInteractionEnabled:YES];'而不是 – LoVo
'[CATransaction setCompletionBlock:^ {NSLog(@「finished」); 自我。 ImageView.userInteractionEnabled = true; }];' – Mahesh
它不能正常工作 – Sumi