2013-04-27 66 views
0

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

enter image description here

我加入uipangesture像在下面的代码uimageviews的数组,但我想uipangesture添加到棕色,绿色和粉红色只彩色图像的观点。

如何在循环中做到这一点?最终,我只想在空的图像视图中平移三个图像浏览。

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

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

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

回答

1

A.为要添加平移手势的图像视图的标记值分配一个数字。

B.在您的for循环中,使用此标记值检查图像视图并添加平移手势识别器。

1

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

+0

真的你确定...? – 2013-04-27 07:58:29

相关问题