UIPageViewController didFinishAnimating not called if swiped quickly

六月ゝ 毕业季﹏ 提交于 2019-11-29 05:51:20

This bug is still here in 2017.. I tried many alternative ways.. now I gave up the hope that this will be fixed by Apple and I think the best way is to use protocol to bound UIPageViewController with content ViewController, so we can notify UIPageViewController in viewDidAppear()

I've got the same issue. I tried to use the UIScrollView delegate instead of UIPageViewController to solve the issue. This is a tricky method, not recommend to use.

1.get the UIScrollView in UIPageViewController to set delegate:

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

2.override scrollViewWillBeginDragging:(UIScrollView *)scrollView

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [[NSNotificationCenter defaultCenter] postNotificationName:PageSwitchingBegan
                                                    object:nil];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    [[NSNotificationCenter defaultCenter] postNotificationName:PageSwitchingEnded
                                                    object:nil];
}

You may also try override - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView instead of scrollViewDidEndDragging to achieve better result.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!