Progress of UIPageViewController

后端 未结 7 1110
礼貌的吻别
礼貌的吻别 2020-12-30 05:51

I would like to receive updates from the uipageviewcontroller during the page scrolling process. I want to know the transitionProgress in %. (This value should update when t

7条回答
  •  感情败类
    2020-12-30 06:13

    Use this -

    for (UIView *v in self.pageViewController.view.subviews) {
        if ([v isKindOfClass:[UIScrollView class]]) {
            ((UIScrollView *)v).delegate = self;
        }
    }
    

    to implement this protocol : -(void)scrollViewDidScroll:(UIScrollView *)scrollView

    and then use @xhist's code (modified) in this way

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
    CGPoint point = scrollView.contentOffset;
    
    float percentComplete;
    percentComplete = fabs(point.x - self.view.frame.size.width)/self.view.frame.size.width;
    NSLog(@"percentComplete: %f", percentComplete);
    }
    

提交回复
热议问题