简体   繁体   中英

iOS temporarily disable Page View Controller swiping

I have a setup where I have a Page View Controller set up to navigate between different views .

In some of these views I will have a custom drawing view where the user can draw with their finger to create a picture.

The problem with this, the user is not able to make a drawing gesture left/right because the page view controller will take over and navigate to a different view.

I was wondering what a good approach would be to temporarily disable the swiping for the page view controller to allow the user to draw .

I was thinking when the user first interacts with the drawing view it would disable the page swiping and create a finished drawing button . When this button is clicked it would reenable the page swiping . Does this seem reasonable, or does anybody know of any better approaches?

Using this you can stop Scrolling

for (UIScrollView *view in self.pageViewController.view.subviews) {

if ([view isKindOfClass:[UIScrollView class]]) {

    view.scrollEnabled = NO;
}
}

I'd look into this UIGestureRecognizerDelegate method:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;

Here you can "kill" the page view controller's gesture recognizer by disabling and re-enabling it:

if (/* otherGestureRecognizer is page view controller's */) {
    otherGestureRecognizer.enabled = NO;
    otherGestureRecognizer.enabled = YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM