ios 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在包中加载 NIB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19025487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:43:32  来源:igfitidea点击:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle

iosobjective-c

提问by N0xus

Trying to run my app on my device and I've got the following SIGART error when I run it:

尝试在我的设备上运行我的应用程序,运行时出现以下 SIGART 错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewController''

由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法加载包中的 NIB:“NSBundle(已加载)”,名称为“ViewController”

I have very limited iOS experience and knowledge but I think it may be relating to the following code snippet in my ViewController.m

我的 iOS 经验和知识非常有限,但我认为这可能与我的 ViewController.m 中的以下代码片段有关

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
    {
        log = [[NSMutableString alloc] init];
    }

    return self;
}

Does anyone know why this is happening?

有谁知道为什么会这样?

回答by Anand Gautam

To fix the problem, I did the following:

为了解决这个问题,我做了以下事情:

  1. Open XCode Target
  2. Go to the "Build phases" tab
  3. Click the "Copy bundle resources" section
  4. Click the add button
  5. Add the missing Nib file
  1. 打开 XCode 目标
  2. 转到“构建阶段”选项卡
  3. 单击“复制捆绑资源”部分
  4. 点击添加按钮
  5. 添加缺少的 Nib 文件

Or This issue is also regarding the nib name. Check the nib name spelling, it's correct, case sensitive.

或者这个问题也与笔尖名称有关。检查笔尖名称拼写,正确,区分大小写。

回答by Sebyddd

Copy your .XIB file somewhere outside the project directory. Delete the file from the project. Add it back again from the saved location.

将您的 .XIB 文件复制到项目目录之外的某个位置。从项目中删除该文件。从保存的位置再次添加它。