Reputation: 1
ScreenShot:
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
Reputation: 535
You can use the UIView's tag property as an identifier and then check it inside your loop.
Upvotes: 1
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