Search code examples
objective-cxcodeuiscrollviewuiswipegesturerecognizer

Xcode, Not able to detect SwipeGesture after i add Animation on my ScrollView


Before start,

UISwipeGestureRecognizer *seipeges=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftswipe:)];
    seipeges.direction=UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:seipeges];

    UISwipeGestureRecognizer *rightgesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightswipe:)];
    rightgesture.direction=UISwipeGestureRecognizerDirectionRight;
    [self.view addGestureRecognizer:rightgesture];

this swipe detect code is run well. after that i add animation on my UIScrollView.

[UIView animateWithDuration:3.0f
                      delay:0.0f
                    options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
                 animations:^{
                     if(leftright==1)
                         [imgCell.scrollview setContentOffset:CGPointMake((-newOffSetX), 0)];
                     else
                         [imgCell.scrollview setContentOffset:CGPointMake(0, 0)];
                 }
                 completion:^(BOOL finished){
                 }];

the animation is run well also. if the animation not yet start, the UISwipeGestureRecognizer is still running well. then i found out, when the animation start, it not able to detect UISwipeGestureRecognizer any more.

so any one can tell me what i missing? or why the SwipeGesture code is not able to run after animation start?


Solution

  • i post the solution at here.

    try setting UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction to the option and see if it works.