开发者

gestureRecognizers - new region

开发者 https://www.devze.com 2023-04-13 08:35 出处:网络
I\'ve changed the region of the screen in which the user can navigate using gestures by creating an arbitrary view (called gestureRegion) and assigning gestureRecognizers to it.

I've changed the region of the screen in which the user can navigate using gestures by creating an arbitrary view (called gestureRegion) and assigning gestureRecognizers to it.

But this only overides the tap gesture.The swipe right and left gestures seems to still work on the entire page. Is there a way to overide the swipe gestures? Or disable it entirely?

My code:

self.gestureRegion.gestureRecognizers = self.pageViewController.gestureRecognizers; [self.pageViewController.view addSubview:gestureRegion];

Apple Doc:

gestureRecognizers An array of UIGestureRecognizer objects that are configured to handle user interaction. (read-only) @property(nonatomic, readonly) NSArray *gestureRecognizers Discuss开发者_如何学Pythonion These gesture recognizers are initially attached to a view in the page view controller’s hierarchy. To change the region of the screen in which the user can navigate using gestures, they can be placed on another view. Availability Available in iOS 5.0 and later. Declared In UIPageViewController.h


It appears that to get rid of the swipe but not the tap you can remove the Pan gesture recognizer from the view... I put this in the viewDidLoad of the RootViewController class in the Xcode auto generated page view app.

for (UIGestureRecognizer *gR in self.pageViewController.gestureRecognizers) {
    if ([gR isKindOfClass:[UIPanGestureRecognizer class]]) {
        [[gR view] removeGestureRecognizer:gR];
    }
}
0

精彩评论

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