我正在开发一个使用 UISlideViewController
的项目。我知道这可能是一个重复的问题,但之前关于这个主题的帖子都没有帮助我。正如我设法理解的那样,我有一个特定的问题。我的应用程序在此 block 上崩溃。我以前读过,将所有与 UI 相关的工作都放在主线程中很重要。这是代码:
pageViewController.setViewControllers([viewController],
direction: direction,
animated: animated,
completion: { completed in
dispatch_async(dispatch_get_main_queue()) {
...
我得到的错误是:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Duplicate states in queue'
*** First throw call stack:
(0x183fd1900 0x18363ff80 0x183fd17d0 0x18494499c 0x1894dc9f4 0x1894dcdec...)
进一步测试我也在同一行代码上得到这个错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No view controller managing visible view <UITableView: 0x12744aa00;
frame = (0 0; 375 515);
clipsToBounds = YES; autoresize = W+H;
gestureRecognizers = <NSArray: 0x12836cf60>;
layer = <CALayer: 0x1286226b0>;
contentOffset: {0, 0}; contentSize: {375, 291}>'
这个错误很难重现。从字面上看,需要在 UIPageViewController 上多次触摸和滚动才能导致崩溃。
感谢您的宝贵时间和帮助。
最佳答案
您应该将 setViewControllers:direction:animated:completion:
代码放在 dispatch_async block
中。它对我有用。
https://stackoverflow.com/a/24749239
关于ios - 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因 : 'Duplicate states in queue' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35195998/