如何从iOS应用程序中的自定义捆绑包加载情节提要文件? [英] How to load storyboard file from custom bundle in IOS app?

查看:149
本文介绍了如何从iOS应用程序中的自定义捆绑包加载情节提要文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在修改的ios应用程序,因此它可以简单地作为静态库插入一系列其他应用程序。但是,我还需要拥有所有相应的资源,因此我创建了一个自定义捆绑包来包含这些资源。捆绑软件包括所有选项卡栏图像,可本地化的字符串,默认图像,以及对此问题最重要的情节提要板文件。当我运行该应用程序时,它无法在自定义捆绑包中找到情节提要文件。

I have an ios app that I am modifying so that it can simply plug-in to a series of other apps as a static library. However, I also need to have all the corresponding resources as well, so I created a custom bundle to include these. The bundle includes all the tab bar images, localizable strings, default images, and, most importantly for this question, the storyboard files. When I run the app, it can't find the storyboard files in the custom bundle.

我的项目布局如下:嗯...看来在我的信誉得分提高之前,我无法发布图片,并且由于我是初学者...我会尽力描述它。

My project is layed out as follows: Hmmmm...ok, it seems I cannot post an image until my reputation score increases, and since I'm a first-timer...I'll do my best to describe it instead.

静态库项目作为子项目拖到主项目中。静态子项目包括2个目标,一个是库,它生成libOMPhotoGalleryLibrary.a文件;一个是libraryResources,它创建OMPhotoGalleryLibraryResources.bundle文件。资源的构建阶段的复制捆绑资源部分包括(以及一堆图像和字符串文件):

The static library project is dragged into the master project as a sub-project. The static sub-project includes 2 targets, the library, which generates the libOMPhotoGalleryLibrary.a file, and the libraryResources, which creates the OMPhotoGalleryLibraryResources.bundle file. The Copy Bundle Resources section of the resource's Build Phases includes (along with a bunch of images and strings files):


  • MainStoryboard_iPad。
    中的情节提要OMPhotoGalleryLibraryResources /(localization.lproj)

  • MainStoryboard_iPad.storyboard in OMPhotoGalleryLibraryResources/(localization).lproj

MainStoryboard_iPhone.storyboard in

OMPhotGalleryLibraryResources /(localization.lproj

MainStoryboard_iPhone.storyboard in
OMPhotGalleryLibraryResources/(localization).lproj

然后,主项目在Linked Frameworks and Libraries部分中包含子项目的静态.a文件,自定义捆绑包包含在其复制捆绑包资源中。

The master project then includes the static .a file of the sub-project in the Linked Frameworks and Libraries section and the custom bundle is included in it's Copy Bundle Resources.

运行项目时,收到消息:
在NSBundle捆绑包中找不到名为'MainStoryboard_iPhone'的故事板

When I run the project, I get the message: Could not find a storyboard named 'MainStoryboard_iPhone' in bundle NSBundle

好的,这并不是完全出乎意料的,因为我需要弄清楚如何告诉应用程序查看自定义捆绑包中的内容。

OK, this is not totally unexpected since I need to figure out how to tell the app to look in the custom bundle instead.

作为调试练习,我(暂时)将主项目中的引用直接添加到情节提要文件中,并使所有内容正常工作。因此,我知道静态库可以正常工作,并且已部署捆绑软件,并且已部署和访问了图像和可本地化的字符串。因此,在删除主项目中的临时引用之后,运行时不再可以再次找到情节提要文件。

As a debug exercise, I (temporarily) added references in the main project directly to the storyboard files and could get everything to work. So, I know that the static library is working properly, and that the bundle is deployed and images and localizable strings are deployed and accessible. So, after removing the temporary references in the main project, the runtime can no longer find the storyboard files again.

我试图将主项目的info部分中的情节提要文件名调整为以下各项,但无济于事:
OMPhotoGalleryLibraryResources.bundle / MainStoryboard_iPhone
OMPhotoGalleryLibraryResources.bundle / zh-CN / MainStoryboard_iPhone
OMPhotoGalleryLibraryResources.bundle / en.lproj / MainStoryboard_iPhone

I've tried to adjust the storyboard file names in the info section of the master project to each of the following to no avail: OMPhotoGalleryLibraryResources.bundle/MainStoryboard_iPhone OMPhotoGalleryLibraryResources.bundle/en/MainStoryboard_iPhone OMPhotoGalleryLibraryResources.bundle/en.lproj/MainStoryboard_iPhone

我还尝试了几种编程方法应用程序删除主项目,但也没有运气。因此,我不确定如何告诉应用程序在OMPhotoGalleryLibraryResources.bundle中查找情节提要文件。情节提要加载后,我就可以成功读取此捆绑包中的所有其他文件。

I've also tried several programmatic approaches in the app delete of the master project, but also with no luck. So, I'm not sure how to tell the app to look for the storyboard file in the OMPhotoGalleryLibraryResources.bundle. I can successfully read all the other files from this bundle once the storyboard loads.

推荐答案

更新03/03/2013:已解决。我的工作是正确的,但是从原始项目中获取的文件位于本地化文件夹en.lproj中。但是,我没有将它们本地化到新的子项目中。当我将文件从en.lproj文件夹中拉出并放到根资源文件夹中,然后将INFO引用更改为OMPhotoGalleryLibraryResources.bundle / MainStoryboard时。

UPDATE 03/03/2013: Solved it. I was on the right track, but the files that I brought over from the original project were in the localized folder en.lproj. However, I didn't localize them in the new sub-project. When I pulled the files out of the en.lproj folder and into the root resources folder, and then changed the INFO references to OMPhotoGalleryLibraryResources.bundle/MainStoryboard it worked.

这篇关于如何从iOS应用程序中的自定义捆绑包加载情节提要文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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