IOS - How to configure UIScrollView in UIPageViewController to start scrolling after re-enabling

I am working on a project with Swipeable Table Cells in UIPageViewController

. UIPageViewController's

UIScrollView

initially disabled. When you scroll a cell, it slowly shows the button with UIPanGestureRecognizer

, and when the button is fully expanded, the Swipeable Table cell sends a message UIPageViewController

(to its delegate) to enable its scrolling.

When scrolling is enabled, I need UIPageViewController

to start scrolling while the user is still swiping. This functionality is similar to Snapchat, where you swipe right in to chat with a friend. But it doesn't trigger scrolling even if enabled UIScrollView

. The user has to lift their finger off the screen and then turn it back on to scroll again to start scrolling to the next view. UIPageViewController

has this code to enable and disable its scrolling:

+(void)enableScrolling
{
    NSLog(@"supposed to enable");
    [myScrollView setScrollEnabled:YES];
    if (myScrollView.isScrollEnabled == YES) {
        NSLog(@"Scroll view is enabled");
    }
    //[myScrollView.panGestureRecognizer setState:(UIGestureRecognizerState *) UIGestureRecognizerStateBegan];
}

+(void)disableScrolling
{
    NSLog(@"supposed to disable");
    [myScrollView setScrollEnabled:NO];
    if (myScrollView.isScrollEnabled == NO) {
        NSLog(@"Scroll view is disabled");
    }
}

      

I am wondering if I need to somehow order to UIPageViewController's

UIPanGestureRecognizer

start scrolling if the user is still scrolling? I am very close to this work. Any advice will be taken into account. Thank.

EDIT:

I added this line of code to my enableScrolling method in the page view controller class:

[myScrollView setContentOffset:[myScrollView.panGestureRecognizer translationInView:myPageViewController.view]];

      

This is my updated method:

+(void)enableScrolling
{
    NSLog(@"supposed to enable");
    [myScrollView setScrollEnabled:YES];
    if (myScrollView.isScrollEnabled == YES) {
        NSLog(@"Scroll view is enabled");
        [myScrollView setContentOffset:[myScrollView.panGestureRecognizer translationInView:myPageViewController.view]];
    }
}

      

My understanding is that when setting the offset of the scroll content to the current position that is being touched, the scrolling needs to be reactivated, but this all makes the whole screen dark.

Any ideas on what I might be doing wrong?

+3


source to share


1 answer


I wonder what you do. I have an application template that I am creating and has the same function, but I decided to place the UIView over the tableViewCells and then display that view by touching it by sliding it to the right and looking at the content below it. when I get to a certain point of the contentOffSet, I activate the enabled scrollView property and disable touch on the UIView, allowing me to navigate to the next page (just like SnapChat). Not sure if this helps, but how do I do it!



0


source







All Articles