質問

I have UIPageViewController with transition style scroll and navigation orientation vertical. In one of the UIViewControllers I have a UITextView. When I try to scroll inside the text view sometimes UIPageViewController catches the pan gesture and tries to move to next view controller. What would be solution to stop UIPageViewController to receive touch events when a user scrolls text view?

I tried to set exclusiveTouch=YES for the text view, but it didn't help.

役に立ちましたか?

解決

I found a solution. You can disable UIPageViewController panning when UITextView is scrolling.

To disable or enable UIPageViewController panning:

-(void)enablePanning:(BOOL) enable
{
    for (UIScrollView *view in self.pageViewController.view.subviews) {
        if ([view isKindOfClass:[UIScrollView class]]) {
            view.scrollEnabled = enable;
        }
    }
}

And to know when UITextView is scrolling we can use UITextViewDelegate methods:

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self enablePanning:YES];
}

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
     [self enablePanning:NO];
} 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top