开发者

Delimit UISwipeGestureRecognizer

there is a way to delimit the swipe only on a specific item?

in this way it works everywhere

UIGestureRecognizer *recognizer;

//RIGHT
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
self.swipeRightReco开发者_StackOverflowgnizer =(UISwipeGestureRecognizer *)recognizer;
swipeRightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;

[self.view addGestureRecognizer:swipeRightRecognizer];
self.swipeRightRecognizer = (UISwipeGestureRecognizer *)recognizer;
[recognizer release];

thanks!


You can add the swipe recognizer to only the view you want to swipe. Or, you can do this:

swipeRightRecognizer.delegate = self;
//...


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
       shouldReceiveTouch:(UITouch *)touch {
    return (touch.view == myViewThatShouldReceiveSwipes);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜