_UIQueuingScrollView抛出的参数异常无效

Ort*_*ntz 15 cocoa-touch uiscrollview uikit ios ios7

我的应用程序包含UIPageViewController中嵌入的UITableViewController,不时会引发此异常:

Invalid parameter not satisfying: [views count] == 3
Run Code Online (Sandbox Code Playgroud)

回溯:

* thread #1: tid = 0x6239fa, 0x03d1d88a libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 25.3
    frame #0: 0x03d1d88a libobjc.A.dylib`objc_exception_throw
    frame #1: 0x0404f448 CoreFoundation`+[NSException raise:format:arguments:] + 136
    frame #2: 0x03428fee Foundation`-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    frame #3: 0x01e7c535 UIKit`-[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 185
    frame #4: 0x01e800ca UIKit`-[_UIQueuingScrollView _didScrollWithAnimation:force:] + 1231
    frame #5: 0x01e7bb57 UIKit`-[_UIQueuingScrollView _scrollViewAnimationEnded:finished:] + 104
    frame #6: 0x0190583c UIKit`-[UIScrollView(UIScrollViewInternal) animator:stopAnimation:fraction:] + 62
    frame #7: 0x0197096e UIKit`-[UIAnimator stopAnimation:] + 533
    frame #8: 0x0197100a UIKit`-[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 325
    frame #9: 0x01970b76 UIKit`-[UIAnimator(Static) _LCDHeartbeatCallback:] + 67
    frame #10: 0x01663b8a QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 48
    frame #11: 0x01663a46 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 310
    frame #12: 0x01663f6b QuartzCore`CA::Display::TimerDisplayLink::callback(__CFRunLoopTimer*, void*) + 123
    frame #13: 0x0400dbd6 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    frame #14: 0x0400d5bd CoreFoundation`__CFRunLoopDoTimer + 1181
    frame #15: 0x03ff5628 CoreFoundation`__CFRunLoopRun + 1816
    frame #16: 0x03ff4ac3 CoreFoundation`CFRunLoopRunSpecific + 467
    frame #17: 0x03ff48db CoreFoundation`CFRunLoopRunInMode + 123
    frame #18: 0x0533b9e2 GraphicsServices`GSEventRunModal + 192
    frame #19: 0x0533b809 GraphicsServices`GSEventRun + 104
    frame #20: 0x01874d3b UIKit`UIApplicationMain + 1225
Run Code Online (Sandbox Code Playgroud)

有没有人已经看过这个或者知道原因是什么?

Or *_*rir 47

编辑:使用此修复程序更长时间后,我仍然可以看到错误,所以这不是完整的修复(好吧......它总是一种黑客攻击).一旦我找到它,我会用实际的解决方案更新.


我使用UIPageViewController遇到了同样的错误.经过几个小时调试问题,我发现原因是在UIPageViewController的setViewControllers的完成处理程序中使用了UIView动画:direction:animated:completion:.

我不知道为什么在那个阶段制作动画会导致断言错误(我没有动画UIPageViewController或其子视图控制器),但是在主队列中使用dispatch_async包装代码块可以解决问题并停止崩溃.

  • 顺便说一下,在我的情况下,"完成块"并不是真正的问题......我在视图中执行动画确实出现了,(可能是在动画完成之前调用);) (4认同)
  • 老兄,这个评论是金色的. (2认同)
  • 节省时间的惊人方法。我正在为一些集合视图单元设置动画,并得到此错误。在分发中包裹了动画,它消失了。 (2认同)

Kor*_*ton 7

尝试以编程方式过渡到新页面时,我看到了此崩溃.对我来说有意义的答案是不允许他们在过渡期间触摸页面视图.

__block UIView *pageView = pageViewController.view;

// Disable page view to not allow the user to interrupt the page view animation and cause crash
pageView.userInteractionEnabled = NO;

[pageViewController setViewControllers:@[viewController] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished) {
    if (finished) {
        pageView.userInteractionEnabled = YES; // re-enable
    }
}];
Run Code Online (Sandbox Code Playgroud)