raju
raju

Reputation: 1

How to add UIPanGestureRecognizer for only three imageviews in a array of imageviews?

ScreenShot:

enter image description here

I am adding uipangesture to an array of uimageviews like in the following code, but I want to add uipangesture to brown, green color and pink color image views only.

How to do this in a loop? Ultimately I want to pan only three imageviews around the empty imageview.

for(int i=0; i<[imageViewArray count]; i++) {

    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];

    [[imageViewArray objectAtIndex:i]addGestureRecognizer:panGesture];}
}

Upvotes: 0

Views: 138

Answers (2)

Douglas Fischer
Douglas Fischer

Reputation: 535

You can use the UIView's tag property as an identifier and then check it inside your loop.

Upvotes: 1

user523234
user523234

Reputation: 14834

A. Assign a number to the tag value of those image views that you want to add pan gesture.

B. In your for loop, check for image view with this tag value and add the pan gesture recognizer.

Upvotes: 1

Related Questions