PDA

View Full Version : drag uitableview




kikko088
Feb 6, 2012, 12:51 PM
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?

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



ppilone
Feb 6, 2012, 12:56 PM
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?