3

I'm working on a project that has Swipeable Table Cells within a UIPageViewController. The UIPageViewController's UIScrollView is initially disabled. When you swipe the cell, it slowly reveals a button via a UIPanGestureRecognizer and when the button is fully revealed, the Swipeable Table Cell sends a message to the UIPageViewController (its delegate) to enable its scrolling.

When the scrolling is enabled, I need the UIPageViewController to start scrolling while the user still has his finger swiping. This functionality is just like Snapchat where you swipe right to chat with a friend. But it doesn't start scrolling even though the UIScrollView was enabled. The user has to take his finger off the screen and then put it back on to swipe again to starting scrolling to the next view. The UIPageViewController has this code to enable and disable it's 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'm wondering if I somehow have to tell the UIPageViewController's UIPanGestureRecognizer to begin scrolling if the user is still swiping further? I'm very close to making this work. Any advice would be appreciated. Thanks.

EDIT:

I've added this line of code to my enableScrolling method in my 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 setting the scroll view content offset to the current position being touched by the should make the scrolling active again, but all this does is make my whole screen dark.

Any ideas on what I might be doing wrong?

Rafi
  • 1,902
  • 3
  • 24
  • 46

1 Answers1

0

Interesting that you're doing it that way. I have an app template I'm building and have the same feature but I decided to put a UIView over the tableViewCells and then have that view respond to a touch, sliding it to the right and viewing the content underneath. when I get to a certain contentOffSet point I activate the enabled property of the scrollView and disable the touch on the UIView allowing me to scroll over to the next page(Just like SnapChat). Not sure if that helps but that's how I'm doing it!