2013-03-30 69 views
2

我有我附加了singleFingerTap識別類似的這樣的對象(縮略圖)的數組:查找單個手指點擊目標

UITapGestureRecognizer *singleFingerTap = 
    [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundThumbnailTapped)]; 
    [self addGestureRecognizer:singleFingerTap]; 

我怎麼能知道我的選擇(backgroundThumbnailTapped)的縮略圖的是挖?

回答

3

更改您選擇的簽名接受手勢識別,就像這樣:

UITapGestureRecognizer *singleFingerTap = 
    [[UITapGestureRecognizer alloc] initWithTarget:self 
     action:@selector(backgroundThumbnailTapped:)]; 
//         Here ----------^ 
    [self addGestureRecognizer:singleFingerTap]; 

-(void) backgroundThumbnailTapped:(UIGestureRecognizer *)gestureRecognizer { 
    // Below, you can get the view to which the recognizer is attached: 
    [gestureRecognizer.view doSomething]; 
    //     ^^^ 
    //     | 
    //  This is the view in which the tap was triggered 
} 

您添加識別時需要把一個冒號