Search code examples
uiviewuiimageviewgesturemultiview

How to use pan gesture on mutiple UIImageView


I develop app that have many view but when i want to move certain view (backgndView) using pan gesture, the other view was moved. Seem my desired view not active. Here the code.

//---pan gesture---
UIPanGestureRecognizer *panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];

[backgndView addGestureRecognizer:panGesture];
[frameView addGestureRecognizer:panGesture];
[effectView addGestureRecognizer:panGesture];
[itemView addGestureRecognizer:panGesture];
[extraView addGestureRecognizer:panGesture];
[panGesture release]; 

I think extraView is active for gesture but not other view. Any other way to make selected view active?

thanks.


Solution

  • Didnt understand problem well but something like blow makes all views active for pan gesture.

    //---pan gesture---

    UIPanGestureRecognizer *panGesture =
    [[UIPanGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(handlePanGesture:)];
    
    [backgndView addGestureRecognizer:panGesture];
    [panGesture release]; 
    
    panGesture =
    [[UIPanGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(handlePanGesture:)];
    [frameView addGestureRecognizer:panGesture];
    [panGesture release]; 
    
    panGesture =
    [[UIPanGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(handlePanGesture:)];
    [effectView addGestureRecognizer:panGesture];
    [panGesture release]; 
    
    panGesture =
    [[UIPanGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(handlePanGesture:)];
    [itemView addGestureRecognizer:panGesture];
    [panGesture release]; 
    
    panGesture =
    [[UIPanGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(handlePanGesture:)];
    [extraView addGestureRecognizer:panGesture];
    
    [panGesture release];