我正在使用自定義UITableViewCell子類的UITableView的自定義滑動事件。我包括我的頭的UIGestureRecognizerDelegate
,並有這viewDidLoad:
UITableView滑動手勢需要接近完美的準確度
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.tableView addGestureRecognizer:swipeLeft];
我swipeLeft方法看起來像這樣:
-(void)didSwipe:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded)
{
CGPoint swipeLocation = [recognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
NSDictionary *clip = [self.clips objectAtIndex:swipedIndexPath.row];
NSLog(@"Swiped!");
}
}
這是工作的排序,但刷卡必須是相當精確的。像幾乎不可能的精確。
我幾乎是通過使用UIPanGestureRecognizer來代替它,但不幸的是,它對於使用全局平移手勢識別器(對於那些感興趣的ECSlidingViewController)的全局側抽屜組件來說並不好。
有沒有辦法解決這個問題?任何幫助將不勝感激,因爲我一直在搜索和瀏覽幾個小時尋找解決方案。
所以是用戶在特定單元格上還是在桌面視圖本身上滑動的點? – MishieMoo 2013-04-08 22:43:31
@MishieMoo一個單元格,但我認爲在整個tableview上實現GR更好,並使用CG點來獲取被刷過的單元格。 – 2013-04-08 22:47:51
作爲一個方面說明,我確實嘗試並將其應用於一個單元格,但我遇到了完全相同的問題。 – 2013-04-08 22:59:15