monavari-lebrecht
monavari-lebrecht

Reputation: 920

How to identify a touched photo in TTThumbsViewController by Three20 via gesture?

I subclassed TTThumbsViewController to integrate an upload process. In return I also want to integrate a deletion-process.

My situation: I added an GestureRecognizer on click a photo:

UILongPressGestureRecognizer* recognizer = [[UILongPressGestureRecognizer alloc] 
                                             initWithTarget:self action:@selector(deleteImage:)];
[self.view addGestureRecognizer:recognizer];

...

- (void)deleteImage:(UILongPressGestureRecognizer*)recognizer {
  __block IMHRemotePhoto *photo = [self.dataSource 
                                    tableView:self.tableView 
                                    objectForRowAtIndexPath:[self.tableView
                                    indexPathForRowAtPoint:gestureStartPoint]];

}

But with that snippet I only identify the row and not the object I selected TTThumbsViewController may have up to 4 elements in a row per default.

Any ideas how to do this?

Best regards, hijolan

Upvotes: 0

Views: 159

Answers (1)

tt.Kilew
tt.Kilew

Reputation: 6084

You always can use hitTest function of UIView

TTThumbView * selectedThumb = [self.tableView hitTest:point withEvent:nil];
if (selectedThumb && [selectedThumb isKindOfClass:[TTThumbView class]]) {
    // Do something with this thumb
}

Upvotes: 0

Related Questions