UIPageViewController 设置滑动事件监听

龚承嗣
2023-12-01

1、先获取UIPageViewController里面的UIScrollView:

-(UIScrollView *)findScrollView{    

    UIScrollView* scrollView;

    for(id subview in _pageViewController.view.subviews){

        if([subview isKindOfClass:UIScrollView.class]){

            scrollView=subview;

            break;

        }}

    return scrollView;

}


2、通过UIScrollView对滑动事件监听:

_scrollView.delegate = self;

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {

    NSLog(@"scrollViewDidScroll: %@, _pageViewController.view = %@",NSStringFromCGPoint(scrollView.contentOffset), _currentVC);

}
 类似资料: