例外:***由于未捕获的异常终止应用程序' NSInternalInconsistencyException',原因:'无法在捆绑中加载NIB

时间:2016-12-21 05:40:29

标签: objective-c ios10 nsexception

我试图在表格View Controller中的iOS10 +中一次又一次地使用.xib文件来加载

 static NSString *reuseIdentifier = @"SessionTableViewCellIdentifier";

SessionTableViewCell *cell = (SessionTableViewCell*)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if( !cell )
{
    cell = [[[NSBundle mainBundle] loadNibNamed:@"SessionTableViewCell" owner:self options:nil] objectAtIndex:0];
}

它在9.3版本上运行良好,但过了一段时间它在iOS 10 +上给了我例外

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/srtekappledemo/Library/Developer/CoreSimulator/Devices/1848F1BA-50B8-41AB-8538-CD741BD1A685/data/Containers/Bundle/Application/391AD08C-1DD7-46A0-A4D0-A07274A72241/ACSuccess.app> (loaded)' with name '3pB-ff-s9x-view-jo5-RS-cHl' and directory 'Main.storyboardc''
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e08fd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010d6d021e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e0f92b5 +[NSException raise:format:] + 197
    3   UIKit                               0x000000010f342bd2 -[UINib instantiateWithOwner:options:] + 507
    4   UIKit                               0x000000010f0d69c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
    5   UIKit                               0x000000010f0d72e7 -[UIViewController loadView] + 177
    6   UIKit                               0x000000010f0d761c -[UIViewController loadViewIfRequired] + 201
    7   UIKit                               0x000000010f0de062 -[UIViewController __viewWillAppear:] + 118
    8   UIKit                               0x000000010f1091d3 -[UINavigationController _startCustomTransition:] + 1290
    9   UIKit                               0x000000010f119e48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
    10  UIKit                               0x000000010f11afdb -[UINavigationController __viewWillLayoutSubviews] + 58
    11  UIKit                               0x000000010f311dd7 -[UILayoutContainerView layoutSubviews] + 223
    12  UIKit                               0x000000010effaab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
    13  QuartzCore                          0x000000010d02ebf8 -[CALayer layoutSublayers] + 146
    14  QuartzCore                          0x000000010d022440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    15  QuartzCore                          0x000000010d0222be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    16  QuartzCore                          0x000000010cfb0318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
    17  QuartzCore                          0x000000010cfdd3ff _ZN2CA11Transaction6commitEv + 475
    18  UIKit                               0x000000010ef607f0 _afterCACommitHandler + 346
    19  CoreFoundation                      0x000000010e034267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    20  CoreFoundation                      0x000000010e0341d7 __CFRunLoopDoObservers + 391
    21  CoreFoundation                      0x000000010e018f8e __CFRunLoopRun + 1198
    22  CoreFoundation                      0x000000010e018884 CFRunLoopRunSpecific + 420
    23  GraphicsServices                    0x0000000111302a6f GSEventRunModal + 161
    24  UIKit                               0x000000010ef35c68 UIApplicationMain + 159
    25  ACSuccess                           0x000000010cbc08ff main + 111
    26  libdyld.dylib                       0x0000000111a7668d start + 1

但是有很多链接,我已经尝试了几乎所有的东西,如下所示:

  1. 您是否在Xcode外重命名了xib或storyboard文件?如果是这样,请检查您所引用的任何地方是否存在不一致。另外,请确保在引用文件的任何地方都尊重大写/小写字母,因为区分大小写。

  2. 转到Interface Builder,选择View1 ViewController&gt;公用事业小组&gt;身份检查员&gt;如果您有一个(.h和.m文件),请检查自定义类是否与您的ViewController类相对应。

  3. 检查目标的构建阶段&gt;复制Bundle Resources并确保在那里添加了xib或storyboard文件。如果以编程方式实例化View1 ViewController并使用xib文件检查错别字的笔尖名称(请记住,区分大小写)。此外,如果您当前将.xib文件格式附加到名称,请删除该扩展名,因为它不应该被使用。我的意思是这行代码: UIViewController *controller = [[UIViewController alloc] initWithNibName:@"xibFileName" bundle:nil];

  4. 在文件检查器中检查xib或情节提要文件的属性,并确保在目标成员资格选择面板中将文件链接到目标。

  5. 检查文件检查器中xib或情节提要文件的属性,并尝试将文件位置切换为相对项目或相对于组。看看两种方式是否有所不同。

  6. 如果您在initWithCoder中以编程方式添加视图控制器,那么您应该在viewDidLoad方法中实例化它

  7. 如果上述情况不适用于您的情况,您可以从Xcode中删除该文件(选择删除引用)并在项目中再次导入。

  8. 检查您的Info.plist文件。如果您使用storyboads,则应该有一个类似于主故事板文件基本名称和NOT主nib文件基本名称的条目。如果使用笔尖,则反之亦然。还要检查文件基名是否与实际文件的名称一致。

  9. 我是否错过了创建此查询的内存泄漏?

0 个答案:

没有答案