简体   繁体   English

如何在图像视图数组中仅为三个图像视图添加UIPanGestureRecognizer?

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

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. 我正在将uipangesture添加到uimageviews数组中,如下面的代码所示,但我想将uipangesture添加到棕色,绿色和粉红色图像视图中。

How to do this in a loop? 如何在循环中执行此操作? Ultimately I want to pan only three imageviews around the empty imageview. 最后,我想在空的imageview周围仅平移三个图像视图。

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

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

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

A. Assign a number to the tag value of those image views that you want to add pan gesture. A.为要添加平移手势的图像视图的标记值指定一个数字。

B. In your for loop, check for image view with this tag value and add the pan gesture recognizer. B.在for循环中,使用此标记值检查图像视图并添加平移手势识别器。

您可以使用UIView的标记属性作为标识符,然后在循环中检查它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM