2013-04-27 67 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

相關問題