开发者

Delimit UISwipeGestureRecognizer

开发者 https://www.devze.com 2023-03-18 07:53 出处:网络
there is a way to delimit the swipe only on a specific item? in this way it works everywhere UIGestureRecognizer *recognizer;

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

精彩评论

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