简体   繁体   English

'NSInternalInconsistencyException'-无法在uinavigationcontroller iOS 6上推送uitableviewcontroller

[英]'NSInternalInconsistencyException' - unable to push uitableviewcontroller on uinavigationcontroller ios 6

I am simply pushing a UITableviewController to navigation stack. 我只是将UITableviewController推送到导航堆栈。 Code works fine in both iOS 4.3 and 5 but crashes in iOS 6. Exception is: 代码在iOS 4.3和5中都可以正常运行,但在iOS 6中崩溃。例外是:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuController" nib but the view outlet was not set.' 由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'-[[UIViewController _loadViewFromNibNamed:bundle:]加载了“ MenuController”笔尖,但未设置视图出口。

I know this exception is raised when view outlet is not set. 我知道未设置视图出口时会引发此异常。 Outlet is set automatically by IB as you can see in figure, but still the same. 如图所示,IB自动设置了出口,但仍然相同。 What am I doing wrong? 我究竟做错了什么?

Simple code pushing the controller: 简单的代码推送控制器:

MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
    menu.title = @"Watches";
    menu.MenuToBeDisplayed = @"main menu";
    [self.navigationController pushViewController:menu animated:YES];

在此处输入图片说明

Stack trace is: 堆栈跟踪为:

 0   CoreFoundation                      0x01f3e02e __exceptionPreprocess + 206
    1   libobjc.A.dylib                     0x01a12e7e objc_exception_throw + 44
    2   CoreFoundation                      0x01f3ddeb +[NSException raise:format:] + 139
    3   UIKit                               0x00a3af18 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
    4   UIKit                               0x00a3b418 -[UIViewController loadView] + 302
    5   UIKit                               0x00b8934e -[UITableViewController loadView] + 80
    6   UIKit                               0x00a3b648 -[UIViewController loadViewIfRequired] + 73
    7   UIKit                               0x00a3b882 -[UIViewController view] + 33
    8   UIKit                               0x00a3bb2a -[UIViewController contentScrollView] + 36
    9   UIKit                               0x00a52ef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
    10  UIKit                               0x00a52fdb -[UINavigationController _layoutViewController:] + 43
    11  UIKit                               0x00a53286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 254
    12  UIKit                               0x00a53381 -[UINavigationController _startTransition:fromViewController:toViewController:] + 72
    13  UIKit                               0x00a53eab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
    14  UIKit                               0x00a544a3 -[UINavigationController pushViewController:transition:forceImmediate:] + 1030
    15  UIKit                               0x00a54098 -[UINavigationController pushViewController:animated:] + 62
    16  Tick                                0x000e5f02 -[MarketWatchViewController openMenu] + 274
    17  libobjc.A.dylib                     0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
    18  UIKit                               0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
    19  UIKit                               0x00b99b24 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
    20  libobjc.A.dylib                     0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
    21  UIKit                               0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
    22  UIKit                               0x0095d8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    23  UIKit                               0x00a1e671 -[UIControl sendAction:to:forEvent:] + 66
    24  UIKit                               0x00a1ebcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    25  UIKit                               0x00a1dd38 -[UIControl touchesEnded:withEvent:] + 546
    26  UIKit                               0x0098d33f -[UIWindow _sendTouchesForEvent:] + 846
    27  UIKit                               0x0098d552 -[UIWindow sendEvent:] + 273
    28  UIKit                               0x0096b3aa -[UIApplication sendEvent:] + 436
    29  UIKit                               0x0095ccf8 _UIApplicationHandleEvent + 9874
    30  GraphicsServices                    0x0291adf9 _PurpleEventCallback + 339
    31  GraphicsServices                    0x0291aad0 PurpleEventCallback + 46
    32  CoreFoundation                      0x01eb3bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    33  CoreFoundation                      0x01eb3962 __CFRunLoopDoSource1 + 146
    34  CoreFoundation                      0x01ee4bb6 __CFRunLoopRun + 2118
    35  CoreFoundation                      0x01ee3f44 CFRunLoopRunSpecific + 276
    36  CoreFoundation                      0x01ee3e1b CFRunLoopRunInMode + 123
    37  GraphicsServices                    0x029197e3 GSEventRunModal + 88
    38  GraphicsServices                    0x02919668 GSEventRun + 104
    39  UIKit                               0x0095a65c UIApplicationMain + 1211
    40  Tick                                0x00002dc5 main + 197
    41  Tick                                0x00002cb5 start + 53

EDIT: 编辑:

I have removed nib file, and also initWithNibName: method, but I am still getting this stupid exception since yesterday. 我已经删除了笔尖文件以及initWithNibName:方法,但是自昨天以来,我仍然收到此愚蠢的异常。 This will drive me crazy :( 这会让我发疯:(

With

MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];

You aren't using your xib file at all becouse for initing contreoller with xib you need to use 您根本没有使用xib文件,因为您需要使用xib来初始化contreoller

initWithNibName:bundle: instead of initWithStyle: initWithNibName:bundle:而不是initWithStyle:

and then set your controller's class on xib like this 然后像这样在xib上设置控制器的类

设置XIB的控制器自定义类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM