0

我有多个图像显示在ImageView中使用交叉溶解动画和录制图像显示图像细节。以下是代码工作,但在从一个图像到另一个图像进行动画处理时,点击imageview失败。iOS:UIImageView没有响应动画之间的水龙头手势

用于将单击手势识别器附加到UIImageview并启动动画计时器的代码。

self.imageView.userInteractionEnabled = YES; 
    self.singleTapGestureRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showDetails)]; 
    self.singleTapGestureRecogniser.numberOfTapsRequired = 1; 
    self.singleTapGestureRecogniser.cancelsTouchesInView = NO; 

    [self.imageView addGestureRecognizer:self.singleTapGestureRecogniser]; 

    [self startAnimationTimer]; 

- (void)startAnimationTimer 
{ 
    if(!self.timer && ![self.timer isValid]) { 
     self.timer = [NSTimer scheduledTimerWithTimeInterval:5.0 
           target:self 
           selector:@selector(startAnimation) 
           userInfo:nil 
           repeats:YES]; 
     [self.timer fire]; 
    } 
} 

上ImageView的一个水龙头工作正常,除非以下代码执行!我必须点击3-4次来打开有关图像的细节。

- (void)startAnimation 
{ 
    [UIView transitionWithView:self.imageView duration:2.0 
         options:UIViewAnimationOptionTransitionCrossDissolve 
        animations:^ { 
         currentImageIndex = ++currentImageIndex % self.images.count; 
         [self.imageView setImage:[[self.images objectAtIndex:currentImageIndex] image]]; 
        } completion:^(BOOL finished) { 
        } 
    ]; 
} 

有人可以请建议我如何摆脱这个问题,请。而在动画的选项

+0

禁止用户交互并完成动画后启用。 – Ashim

+0

我不想禁用用户交互。我想在任何时候识别轻拍事件,包括动画制作。 – applefreak

+0

你能告诉我崩溃日志吗? – Ashim

回答

4

集UIViewAnimationOptionAllowUserInteraction像这样

[UIView transitionWithView:self.imageView duration:2.0 
         options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction 
        animations:^ { 
         currentImageIndex = ++currentImageIndex % self.images.count; 
         [self.imageView setImage:[[self.images objectAtIndex:currentImageIndex] image]]; 
        } completion:^(BOOL finished) { 
        } 
    ]; 
+0

太棒了!我不知道这个选项。谢谢。 :-) – applefreak

+1

@applefreak:如果您满足于此答案,则将其标记为已接受的答案。 –

+0

对不起,我试图立即接受它,但所以要求我等5分钟! – applefreak

相关问题