UIPageViewController NSInternalInconsistencyException [英] UIPageViewController NSInternalInconsistencyException

查看:854
本文介绍了UIPageViewController NSInternalInconsistencyException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的 UIPageViewController ,它有两个页面。每个页面都是从不同的 ViewController 加载,其特定的 xib 文件名为 PViewController TViewController

I'm developing a simple UIPageViewController that has two pages. Each page is loaded from a different ViewController with their specific xib files, named PViewController and TViewController.

对于 PViewController ,有三种不同的视图,让我们称之为 A B C 。当应用程序启动时, PViewController 成功显示,我可以向左滑动以查看 TViewController ,也没有问题。但是,当我在 PViewController 中,作为对事件的响应,我将当前视图 A 更改为另一个视图,然后向左滑动去 TViewController ,我收到以下异常并且应用程序终止:

For PViewController, there are three different views, let's call them A, B, and C. When the application launches, PViewController appears successfully and I can swipe left to see the TViewController, also with no problems. However, when I'm in PViewController and as a response to an event I change the current view A to another view B, then swipe left to go to TViewController, I receive the following exception and the application terminates:

*** Assertion failure in -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:], /SourceCache/UIKit_Sim/UIKit-2935.137/_UIQueuingScrollView.m:338
2014-07-10 13:57:23.389 ***** [2012:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected subviews'
*** First throw call stack:
(
    0   CoreFoundation                      0x01fde1e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01c418e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01fde048 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x018214de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x00f3cc14 -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:] + 261
    5   UIKit                               0x00f3d248 -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 812
    6   UIKit                               0x00f3d690 -[_UIQueuingScrollView _viewAtIndex:loadingIfNecessary:updatingContents:animated:] + 421
    7   UIKit                               0x00f40c65 __54-[_UIQueuingScrollView _didScrollWithAnimation:force:]_block_invoke + 110
    8   UIKit                               0x00f408de -[_UIQueuingScrollView _didScrollWithAnimation:force:] + 579
    9   UIKit                               0x00f3c452 -[_UIQueuingScrollView layoutSubviews] + 186
    10  UIKit                               0x00970964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    11  libobjc.A.dylib                     0x01c5382b -[NSObject performSelector:withObject:] + 70
    12  QuartzCore                          0x04be445a -[CALayer layoutSublayers] + 148
    13  QuartzCore                          0x04bd8244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    14  QuartzCore                          0x04bd80b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    15  QuartzCore                          0x04b3e7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    16  QuartzCore                          0x04b3fb85 _ZN2CA11Transaction6commitEv + 393
    17  QuartzCore                          0x04b40258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    18  CoreFoundation                      0x01fa636e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    19  CoreFoundation                      0x01fa62bf __CFRunLoopDoObservers + 399
    20  CoreFoundation                      0x01f839eb CFRunLoopRunSpecific + 491
    21  CoreFoundation                      0x01f837eb CFRunLoopRunInMode + 123
    22  GraphicsServices                    0x030285ee GSEventRunModal + 192
    23  GraphicsServices                    0x0302842b GSEventRun + 104
    24  UIKit                               0x00901f9b UIApplicationMain + 1225
    25  *******                             0x000239fd main + 141
    26  libdyld.dylib                       0x02cc1701 start + 1
    27  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是我为UIPageViewController实现的协议方法:

Here is the protocol methods I implemented for the UIPageViewController:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
    UIViewController *vc;

    if(self.index==1) {
        vc = (PViewController *)[[PViewController alloc] initWithNibName:@"PViewController" bundle:nil];
    }
    self.index--;


    return vc;
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
    UIViewController *vc;



    if(self.index==0)
        vc = (TViewController *)[[TViewController alloc] initWithNibName:@"TViewController" bundle:nil];

    self.index++;


    return vc;
} //The exception occurs exactly when the app reaches this point.

这就是我在视图控制器中切换视图的方式,只需要:$ /
$ b

And this is how I switch views within a view controller, simply:

self.view = self.B; 

问题:

我无法追踪问题。我不知道在哪里抓住这个异常或是什么造成的?

I'm not able to track down the problem. I don't know where to catch this exception or what is causing it?

推荐答案

使用发布时传递的以下参数,我偶然遇到同样的错误:

I happened to stumble upon the same error when using the following argument passed on launch:

-UIViewShowAlignmentRects YES

浪费后2天试图在我的UIPageViewController中找到错误,原来在禁用XCode生成的黄色矩形包装器后,NSInternalConsistencyException被消除。

After wasting 2 days trying to find error within my UIPageViewController, it turned out that after disabling XCode generated yellow rectangle wrappers, the NSInternalConsistencyException evaporated.

这篇关于UIPageViewController NSInternalInconsistencyException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆