Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kikko088

macrumors member
Original poster
Oct 13, 2010
77
0
Italy
I have a little problem, I try to drag a UITableview, with this code I drag a view but I can't drag a uitableivew, where is the problem?why I can drag a view/button/image but not a table?

Code:
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.table addGestureRecognizer:panGesture];

- (void)handlePan:(UIPanGestureRecognizer *)recognizer {

    CGPoint translation = [recognizer translationInView:self.view];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
    [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
    [self.view bringSubviewToFront:recognizer.view];

}

I work on an iPad application


kikko088
 
Have you verified that your pan gesture handler is being called? My guess is that the table view is handling the pan gesture in order to support scrolling. If this is the case you have 2 problems:

1. You'll have to handle which view's gestures get recognized.
2. Are you sure you want to support dragging of a UITableView? As a user, would I still be able to scroll the table view without accidentally dragging it?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.