Ios 多次调用SetViewController(方向:动画:完成:)时崩溃

Ios 多次调用SetViewController(方向:动画:完成:)时崩溃,ios,uipageviewcontroller,Ios,Uipageviewcontroller,我有一个基于索引的自定义UIPageViewController,在其中我尝试实现一个显示下一页或上一页的移动方法。大多数答案告诉我们,以编程方式设置当前页面的唯一方法是调用setViewControllers(方向:动画:完成:)方法,但当我从按钮调用此方法并多次单击它时,异常会很快抛出: Exception NSException * "Unexpected view controller: <MyPageViewController: 0x106175ef0>

我有一个基于索引的自定义UIPageViewController,在其中我尝试实现一个显示下一页或上一页的移动方法。大多数答案告诉我们,以编程方式设置当前页面的唯一方法是调用
setViewControllers(方向:动画:完成:)
方法,但当我从按钮调用此方法并多次单击它时,异常会很快抛出:

Exception   NSException *   "Unexpected view controller: <MyPageViewController: 0x106175ef0>"   0x00000002800fa460

name    __NSCFConstantString *  "NSInternalInconsistencyException"  0x0000000200e3dac0
reason  __NSCFString *  "Unexpected view controller: <MyPageViewController: 0x106175ef0>"   0x0000000282492680
在我的自定义UIPagerViewController中,我在
UIPageViewControllerDataSource
中保留3个页面并在它们之间循环移动

为什么会发生这种错误?现在,我禁用next按钮直到页面更改结束(通过
completion
arg),但我认为这不是一个好的解决方案,因为它限制了页面更改的速度

以下是一些错误日志:

2020-09-24 11:24:06.619878+0800 MyApp[976:249262] *** Assertion failure in -[MyUIPageViewController queuingScrollView:willManuallyScroll:toRevealView:concealView:animated:], /Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3920.31.102/UIPageViewController.m:1959
2020-09-24 11:24:06.620689+0800 MyApp[976:249262] 
2020-09-24 11:24:06.620813+0800 MyApp[976:249262] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected view controller: <MyApp.MyPageViewController: 0x106175ef0>'
*** First throw call stack:
(0x1bf749654 0x1bf46bbcc 0x1bf64c6ec 0x1bfa9216c 0x1c314c940 0x1c3156d94 0x1c31581fc 0x1c3157d50 0x1c3153f78 0x1c3cb17fc 0x1c624e494 0x1c62545ec 0x1c625f128 0x1c61a7b44 0x1c61d14e4 0x1c610e120 0x1c0698650 0x1bf69eb34 0x1bf6c8174 0x1bf6c7880 0x1bf6c2634 0x1bf6c1ba8 0x1c9831344 0x1c37fd3e4 0x1049dcea0 0x1bf5498f0)
libc++abi.dylib: terminating with uncaught exception of type NSException
2020-09-24 11:24:06.619878+0800 MyApp[976:249262]***-[MyUIPageViewController queuingScrollView:willManuallyScroll:toRevealView:HiddenView:animated:],/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3920.31.102/UIPageViewController.m:1959中的断言失败
2020-09-2411:24:06.620689+0800 MyApp[976:249262]
2020-09-24 11:24:06.620813+0800 MyApp[976:249262]***由于未捕获的异常“NSinternalinconsistenceException”而终止应用程序,原因:“意外的视图控制器:”
***第一次抛出调用堆栈:
(0x1bf749654 0x1BF46BCC 0x1bf64c6ec 0x1bfa9216c 0x1c314c940 0x1c3156d94 0x1c31581fc 0x1c3157d50 0x1c3153f78 0x1c3cb17fc 0x1C6244E494 0x1c62545ec 0x1c625f128 0x1c61a7b44 0x1c610e120 0x1c0698650 0x1bf69eb34 0x1bf6c8174 0x1bf6c7880 0x1bf6c2634 0x1bf6c1ba8 0x98344 0x1C37FD3E490BF8F50)
libc++abi.dylib:以NSException类型的未捕获异常终止