使用iOS上已下载的软件包中包含的XIB / NIB文件 [英] Using XIB/NIB files contained within downloaded bundles on iOS

查看:113
本文介绍了使用iOS上已下载的软件包中包含的XIB / NIB文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从表面上看,这似乎是一个非常简单的问题,但由于某些原因,我无法让它发挥作用。

On the face of it, this seems a very simple problem but for some reason I can't quite get it to work.

我有一个杂志式以压缩包的形式下载每个问题的数据的应用程序。

I have a magazine-style app that downloads the data for each issue in the form of a zipped bundle.

下载并解压后,应用程序成功访问包中包含的各种文件。这些包括JSON,PNG,JPG,视频等。

Once downloaded, and unpacked, the app successfully accesses the various files contained within the bundle as expected. These include JSON, PNG, JPG, video and so on.

但是,我还包含了一个XIB文件,其中包含一系列UIView中内容的物理布局和这是我无法使用的文件。

However, I also included a XIB file that contains the physical layout of the content in a series of UIViews and it is this file that I cannot use.

该文件存在,但是当我尝试使用以下文件加载时:

The file is present but when I try and load it using:

UIViewController *controller = [[UIViewController alloc] initWithNibName: @"ViewController" bundle: assetBundle];

我收到以下错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/C6718DB8-0C0F-4D38-84E6-55C145279957/Documents/asset-4.bundle> (not yet loaded)' with name 'ViewController''

现在,这是iOS施加的限制吗没有从下载的软件包中访问XIB,或者我在调用XIB时遇到了一些错误?

Now, is this an iOS imposed limitation on not accessing XIBs from downloaded bundles, or some mistake I'm making in calling up the XIB for use?

但是我发现没有明确禁止以这种方式使用fetched bundle。

I cannot find any explicit prohibition on using fetched bundles in this way however.

推荐答案

我不确定你是否可以合法地逃脱这一点。但问题是你可能正在使用'xib'代替编译版本'nib'。

I am unsure if you can 'legally' get away with this. But the problem is likely you are suppling a 'xib' instead of the compiled version the 'nib'.

你可以使用提供的方法从命令行手动执行此操作 ibtool program。

You can do this manually from the command line by using the provided ibtool program.

ibtool --errors --warnings --output-format human -readable-text --compile $ {OUTPUT_NAME} $ {INPUT_NAME}

然后,您将已编译的.nib文件放入捆绑包中你正在尝试加载。

You'd then place the compiled .nib file into the bundle and load as you've been trying.

这篇关于使用iOS上已下载的软件包中包含的XIB / NIB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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