无法在捆绑包中加载 NIB:“NSBundle”

发布于 2024-10-18 23:29:32 字数 354 浏览 6 评论 0原文

下面列出的错误是什么?

2011-02-23 21:24:12.218 Success[7238:207] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在捆绑包中加载 NIB:”NSBundle < ;/Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (已加载)”,名称为“MainWindow-iPad”

What is the error listed below?

2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (loaded)' with name 'MainWindow-iPad''

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

感情废物 2024-10-25 23:29:32

项目中缺少一个 NIB 文件,请添加所需的 NIB 文件:

在“构建阶段”中

  1. 展开“复制捆绑资源”,
  2. 单击底部的 +
  3. 添加所需的 NIB 文件。

通过 Shift+Cmd+K 清理构建,然后运行。

PS 另外,请确保在调用 initWithNibName:@"ViewNameController"使用 NIB 文件的准确拼写

可能,您在通话中使用小写字母命名您的 NIB,或者您可能还添加了不需要的扩展名 .xib

One of your NIB file is missing from project, add the required NIB file:

In Build Phases

  1. expand Copy Bundle Resources
  2. click + at bottom
  3. add the required NIB file.

Clean your build by Shift+Cmd+K, then run.

P.S. Also make sure to use exact spelling of NIB file while calling initWithNibName:@"ViewNameController"

Probably, you have named your NIB in a call by lowercase letters or you may have also included extension .xib which is not required.

半枫 2024-10-25 23:29:32

可能您在调用中用小写字母命名了您的 NIB。在这种情况下,模拟器工作正常,但 iPhone 设备将在运行时返回错误。

例如,

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"detailViewController" bundle:nil];

会失败。您需要更改为:

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"DetailViewController" bundle:nil];

Probably, you have named your NIB in a call by lowercase letters. The simulator works fine in this case, but an iPhone device will return an error during runtime.

For example,

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"detailViewController" bundle:nil];

will fail. You need to change to:

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"DetailViewController" bundle:nil];
旧时光的容颜 2024-10-25 23:29:32

在构建设置中,添加架构 =>> armv6 和 armv7

我刚刚使用这个删除了我的错误

In your Build Settings, Add Architecture =>> armv6 and armv7

I just removed my error using this

浪漫人生路 2024-10-25 23:29:32

我遇到了同样的问题,但这是因为我写了扩展名 .xib 而不是必需

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad.xib" bundle:nil];

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad" bundle:nil];

I have got the same problem, but it was because i wrote the extension .xib and it is not neccessary

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad.xib" bundle:nil];

instead of

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad" bundle:nil];
豆芽 2024-10-25 23:29:32

就我而言,接下来是:

我加载了名为“??????Ipad”的代码 XIB
但 XIB 文件名是“??????iPad”

In my case was next:

I loaded in code XIB with name "??????Ipad"
but XIB filename was "??????IPad"

不必了 2024-10-25 23:29:32

是否有与 NIB 相关的警告?这通常是针对 NIB 文件中的错误(例如 NIB 类型不正确)执行的。

右键单击该文件,然后单击“获取信息”以验证该类型是否符合您的预期。

Are there any warnings related to the NIB? This is usually do to an error in the NIB file (such as incorrect type of NIB).

Right click on the file and click "Get Info" to verify that the type is what you would expect.

朕就是辣么酷 2024-10-25 23:29:32

另一个可能的问题:您正在使用iOS 5 上的基本本地化(注意,它在 iOS 模拟器上可以工作,但不能在设备上工作),但仅从 iOS 6 开始支持它。

了解更多信息,请参阅:无法在捆绑包基础国际化中加载笔尖

An other possible issue: you are using Base Localization on iOS 5 (caution, it kinda work on the iOS Simulator, but not on a device), but it is supported only starting from iOS 6.

For more info, see: Could not load nib in bundle base internationalization

千年*琉璃梦 2024-10-25 23:29:32

请确保您的 nib/xib 文件包含在相应的目标会员资格中。

Please make sure your nib/xib file is included in the corresponding Target Membership.

吃素的狼 2024-10-25 23:29:32

我有同样的问题,只需按照步骤操作即可。

1.将您的项目复制到另一个地方。

2.复制崩溃应用程序的 NIB 文件。

3.只需更改名称

即可旧文件 Demo.xib 比复制并更改名称 DemoNew.xib

我的代码低于

旧代码,

Demo *controller = [[Demo alloc]initWithNibName:@"Demo" bundle:nil];

我只是更改名称

Demo *controller = [[Demo alloc]initWithNibName:@"DemoNew" bundle:nil];

,它对我有用。

I Have Same Problem Just Follow Steps.

1.Copy your Project In Another Place.

2.Copy your NIB File Which Crash app.

3.Just Change Name

Ex. Old File Demo.xib Than Copy And Change Name DemoNew.xib

My Code is Below

Old Code

Demo *controller = [[Demo alloc]initWithNibName:@"Demo" bundle:nil];

I Just Change Name

Demo *controller = [[Demo alloc]initWithNibName:@"DemoNew" bundle:nil];

its working for me.

睫毛溺水了 2024-10-25 23:29:32

只需检查您的项目中是否存在文件 MainWindow.xib 即可。如果没有,只需添加名为 MainWindow.xib 的新界面文件。

Just check that file MainWindow.xib exist in your project. If not, just add the new interface file with name MainWindow.xib.

你穿错了嫁妆 2024-10-25 23:29:32

如果您尝试在从笔尖拾取的集合视图中加载collectionView单元,那么您可能会看到错误“'NSInternalInconsistencyException',原因:'无法在捆绑包中加载NIB:' NSBundle“
当您从 nib 文件加载集合视图时,您无法选择在 nib 上声明集合视图单元格,这与故事板不同。
正确的方法是使用新的笔尖创建一个新的自定义单元格,然后将其加载到集合视图中。
注意:不要忘记注册新的自定义收集单元的笔尖。

If you are trying to load a collectionView cell in a collection view which is picked up from a nib then you might be seeing the error" 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle "
When you are loading a collection view from a nib file, you do not have the option to declare a collection view cell on the nib unlike story board.
The correct way is to create a new custom cell , with a new nib and then load it on to the collection view.
Note : don't forget to register the nib of the new custom collection cell.

孤单情人 2024-10-25 23:29:32

就我而言,错误是“nib 文件的名称不正确:

collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "Cell")

建议将它们全部设置为相同,单元格标识符和 nibName 也如此:

collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "CollectionViewCell")

如果不起作用,请尝试以下操作:

Target -> Build Phases -> Copy Bundle Resources

您会发现您的 xib/storyborad 为红色,

只需将其删除即可。此外,从项目中删除丢失文件的所有引用。

现在再次拖动该 storyboard/xib 文件 。到此复制捆绑资源。它仍然会显示一个红色文件,但不用担心

它会清理项目。

In my case, the error was "Incorrect name for nib file in:

collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "Cell")

Recommend making all of them the same, the cell identifier and nibName as well so make it:

collectionViewOutlet.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "CollectionViewCell")

If it doesn't work try this:

Target -> Build Phases -> Copy Bundle Resources

You will find your xib/storyborad with red color.

Just remove it. Also, remove all references of the missing files from the project.

Now drag this storyboard/xib file again to this Copy Bundle Resources. It will still show you a file with red color but don't worry about it.

Command + Shift + K to clean the project and it will work.

深陷 2024-10-25 23:29:32

就我而言(使用 XCode 12.5 和 Swift 5),问题是我根据 ViewController 的名称选择了 NIBName:

let nibName = String(describing: type(of: self)) 
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: nibName, bundle: bundle)
let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView

所以我有“TestView.xib”和“TestViewController.swift”。这不匹配,只能通过将我的 ViewController 重命名为“TestView.swift”来解决。

In my case (using XCode 12.5 and Swift 5) the problem was that I choosed the NIBName based on the name of my ViewController:

let nibName = String(describing: type(of: self)) 
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: nibName, bundle: bundle)
let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView

So I had "TestView.xib" and "TestViewController.swift". This mismatched and could only be resolved by renaming my ViewController to "TestView.swift".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文