如何解决“无法确定滚动的导航方向”错误 [英] How to solve "Failed to determine navigation direction for scroll" bug
问题描述
我最常见的错误是无法确定导航方向滚动的原因,任何关于我如何解决的想法?
My most frequent bug has "Failed to determine navigation direction for scroll" for reason, any idea about how I could solve it?
这是最后一个异常回溯:
Here is the last Exception Backtrace:
1. CoreFoundation __exceptionPreprocess + 131
2. libobjc.A.dylib _objc_exception_throw + 39
3. CoreFoundation +[NSException raise:format:] + 1
4. Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 91
5. UIKit __54-[_UIQueuingScrollView _didScrollWithAnimation:force:]_block_invoke + 221
6. UIKit -[_UIQueuingScrollView _didScrollWithAnimation:force:] + 567
7. UIKit -[_UIQueuingScrollView _scrollViewAnimationEnded:finished:] + 73
8. UIKit -[UIAnimator stopAnimation:] + 471
9. UIKit -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 285
10. UIKit -[UIAnimator(Static) _LCDHeartbeatCallback:] + 53
11. QuartzCore CA::Display::DisplayLinkItem::dispatch() + 99
12. QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 345
13. IOMobileFramebuffer IOMobileFramebufferVsyncNotifyFunc + 105
14. IOKit _IODispatchCalloutFromCFMessage + 249
15. CoreFoundation __CFMachPortPerform + 137
16. CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35
17. CoreFoundation __CFRunLoopDoSource1 + 347
18. CoreFoundation __CFRunLoopRun + 1399
19. CoreFoundation _CFRunLoopRunSpecific + 523
20. CoreFoundation _CFRunLoopRunInMode + 107
21. GraphicsServices _GSEventRunModal + 139
22. UIKit _UIApplicationMain + 1137
23. MyApp main (main.m:13)
更新:
我终于设法重现在模拟器上的bug,这是当我接触到一个视图,同时,UIPageViewController滚动动画启动程序员可以。基本上,如果您以编程方式将动画设置为yes并滚动动画来设置ViewsController。如果您在滚动动画开始之前触摸屏幕的任何部分,将会出现以下崩溃 在 - [_ UIQueuingScrollView _didScrollWithAnimation:force:],/ SourceCache / UIKit / UIKit-2372 / _UIQueuingScrollView.m:778,如此处所述。
UPDATE : I finally managed to reproduce the bug on the simulator, it's when I'am touching a view and that at the same time, the UIPageViewController scroll animation starts programmatically. Basically, if you setViewsControllers programmatically with animation set to yes and scroll animation. If you're touching any part of the screen before the scroll animation starts there will be the following crash * Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778 as described here .
我还下载了Apple的PhotoScroller示例应用程序,并用编程页面更改进行了编辑,并且具有相同的错误。
I also downloaded Apple's PhotoScroller sample app and edited it with programmatic page change and they have the same bug.
如果用户当前正在触摸屏幕,我的解决方案不会触发页面更改,还可以将动画更改为卷曲或删除动画。
My solution was not to trigger the page change if the user is currently touching the screen, you can also change the animation to curl or remove the animation.
推荐答案
理想情况下,我们想知道底层的 UIScrollView
是否被拖动或减速。但是苹果不允许公开访问页面控制器中的 UIScrollView
,所以我们可以通过这两个代理跟踪BOOL的页面控制器的转换状态。
Ideally we would want to know whether the underlying UIScrollView
is being dragged or decelerating. But Apple doesn't allow public access to the UIScrollView
in the page controller, so we can keep track of the page controller's transition state with a BOOL via these two delegates.
- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers
{
self.transitioning = YES;
}
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
{
if (finished) {
self.transitioning = NO;
}
}
在代码中以编程方式转换页面视图,只有如果页面控制器尚未转换,请继续执行。
In your code to programmatically transition the page views, only proceed if the page controller isn't already transitioning.
if (!self.isTransitioning) {
[self.pageController setViewControllers:@[toViewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
}
这篇关于如何解决“无法确定滚动的导航方向”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!