UIPageViewController中的

UIPageViewController中的

在UIPageViewController中的选项卡之间切换太快时,应用程序崩溃

[UIPageViewController queuingScrollView:didEndManualScroll:toRevealView:direction:animated:didFinish:didComplete:]

错误,由于未捕获的异常“NSInternalInconsistencyException”而导致断言失败并终止应用程序,原因:“无 View Controller 管理可见 View 。

错误日志如下
*** Assertion failure in -[UIPageViewController queuingScrollView:didEndManualScroll:toRevealView:direction:animated:didFinish:didComplete:], /SourceCache/UIKit/UIKit-3318.0.1/UIPageViewController.m:1875
2014-09-29 11:34:00.770 Wowcher[193:9460] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No view controller managing visible view <UIView: 0x1783fa80; frame = (0 0; 320 416); autoresize = W+RM+H+BM; layer = <CALayer: 0x17898540>>'
*** First throw call stack:
(0x219fbf87 0x2f15ac77 0x219fbe5d 0x226cb2c9 0x253f9fff 0x2546f8d3 0x2546f6b7 0x2546c2b9 0x254700db 0x25470f97 0x2546d037 0x24ea925f 0x2500a589 0x24ff7eef 0x24ea677d 0x252b8c81 0x24e70105 0x24e6e07f 0x24ea4b6d 0x24ea443d 0x24e7acc5 0x250ee513 0x24e79707 0x219c2807 0x219c1c1b 0x219c0299 0x2190ddb1 0x2190dbc3 0x28c99051 0x24ed9a31 0xd950b 0xca6e0)
libc++abi.dylib: terminating with uncaught exception of type NSException

提前致谢

最佳答案

因此,我的解决方案是添加一个BOOL来跟踪我的动画状态。因此,在设置新的ViewController之前,我也对此进行了修改:

if (!_transitionInProgress) {
    _transitionInProgress = YES;
    [self.pageController setViewControllers:@[viewController] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:^(BOOL finished) {
        _transitionInProgress = !finished;
    }];
}

因此,在设置新的 View Controller 之前,我将等待动画完成。就我而言,我有一些按钮,用户可以按这些按钮来切换页面。这也可以防止它们过快地通过动画,因此动画始终流畅而美观

关于ios - UIPageViewController中的断言失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25740245/

10-09 16:52