カスタム UITableViewCell サブクラスを使用する UITableView のカスタム スワイプ イベントに取り組んでいます。UIGestureRecognizerDelegate
をヘッダーに含め、これをviewDidLoad:
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) を使用するグローバル サイド ドロワー コンポーネントではうまくいきませんでした。
これを回避する方法はありますか?私は解決策を探して何時間もSOをグーグル検索して閲覧してきたので、どんな助けもいただければ幸いです。