0
我有一個小問題,我嘗試拖動一個UITableview,這個代碼我拖動一個視圖,但我不能拖動一個uitableivew,問題在哪裏?拖動UITableView
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];
}
我在iPad上的應用程序
我相信你會有任何'UIScrollView'子類(和'UITableView'是一個哦,這些類)相同的問題,因爲它處理觸摸本身。框架實現的方式,它不知道你是否試圖滾動表或拖動它 – 2012-02-06 19:03:26
你是對的,我以另一種方式解決,我添加了一個minimumNumberOfTouches,所以如果用戶想移動表可以移動它用兩根手指,而用一根手指,他可以滾動桌子! – kikko088 2012-02-07 19:28:12