问题描述
我有一个工作原理的UIPageViewController。我可以左右滚动,当我滚动每个方向时,调用委托方法 didFinishAnimating
。但是,如果我滚动太快,我最终在一个页面 didFinishAnimating
不被调用,虽然它被调用所有以前的页面。有人知道为什么会发生这种情况吗?
I have a UIPageViewController that works as expected. I can scroll left and right and the delegate method didFinishAnimating
is called when I scroll each direction. However, if I scroll too quickly I end up on a page where didFinishAnimating
is not called, though it is called for all previous pages. Does anyone know why this might be happening?
我认为 didFinishAnimating
(例如,即使轮到中止)。
I would think that didFinishAnimating
would be called on every page transition regardless (e.g., even if the turn was aborted).
推荐答案
我有同样的问题。我试图使用 UIScrollView委托
而不是 UIPageViewController
来解决问题。
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. UIScrollView
在 UIPageViewController
中设置委托:
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
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];
}
您也可以尝试覆盖 - (void)scrollViewDidEndDecelerating :(UIScrollView *)scrollView
而不是 scrollViewDidEndDragging
,以获得更好的效果。
You may also try override - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
instead of scrollViewDidEndDragging
to achieve better result.
这篇关于UIPageViewController didFinishAnimating如果快速滑动不调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!