具有单独.xib的两个目标(具有相同名称的图像资源) [英] Two targets with separate .xib (image resources with same names)

查看:120
本文介绍了具有单独.xib的两个目标(具有相同名称的图像资源)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个目标的项目,比方说 appA appB

I have a project with two targets, let's say appA and appB.

两个目标主视图控制器的共享代码(appViewController)除了.xib 文件。

Both targets share code of main view controller (appViewController) except the .xib files.

我还有两套每个目标的png

我的文件/项目结构如下:

My file/project structure looks like:

*common* (members of both targets):
    appViewController.h
    appViewController.m

*appA* (members of target appA):
    appViewController.xib
    set of png files

*appB* (members of target appB):
    appViewController.xib
    set of png files

两组中的PNG具有相同的名称,但它们被放置在单独的文件夹/组中,并且一组是一个目标和另一个目标的另一个目标(与appViewController.xib相同)

PNG's in both sets have the same names but they are placed in separate folders/groups and one group is member of one target and the other of the other target (same with appViewController.xib)

一切正常,除非它我想在IB中编辑.xib文件 - 它会让
感到困惑并显示部分来自一个目标的图像,部分来自另一个目标。

由于.xib有点复杂(> 40张图像),编辑部分错误的图像是
几乎不可能 - 图像必须正确放置在一张背景图像上(appA和appB的背景图像也不同)。

Since .xib's are somewhat complex (>40 images) editing one with partly wrong images is almost impossible - images have to be properly placed on one background image (background image is also different for appA and appB).

问题仅在编辑时存在(在IB中)。编译后,
两个目标中的所有图像都是正确的。

The problem exists only at edit-time (in IB). After compilation all the images in both targets are correct.

我找到了一个快速&解决这个问题。在我开始编辑一个.xib
之前,我删除对另一组png的引用。这样IB显示正在编辑的.xib的正确图像
。当我完成时,我只是导入所有引用(其他
目标的png)。

I found one quick & dirty solution to this. Before i start editing one .xib i remove references to the other set of png's. That way IB shows correct images for the .xib i'm editing. I simply import back all the references (png's of the other target) when i'm done.

我发现熟悉的问题没有得到真正的回答。

I found a similiar question which was not really answered.

我想知道,有人有更清洁的解决方案吗?必须有一个更好的方法来做到这一点。

I wonder, does anyone have a cleaner solution to this? There has to be a better way to do it.

推荐答案

到目前为止没有答案......

No answers so far...

所以让我回答一下我自己的问题(仍然希望得到更好的答案)。

So let me answer my own question (still hoping for a better answer).

当你想编辑一个目标的.xib时,你删除了其他目标资源(pngs)的引用

When you want to edit .xib of one target, you remove the references of the other targets' resources (pngs).

然后你退出xcode并再次打开你的项目。 pngs将是
正确的(因为xcode目前没有引用错误的
)。

Then you quit xcode and open your project again. The pngs will be the right ones (since xcode doesn't hold references to the wrong ones at the moment).

当你'重做 - 重新导入已删除的引用(请注意你
检查正确的'目标成员资格')。

When you're done - reimport deleted references (take care that you check the right 'target membership').

编辑:这似乎是IB的一个已知问题 - XCode。直到他们解决它,我们只需要使用上面提到的解决方法。

This seems to be a known issue with IB - XCode. Till they resolve it we'll just have to use workaround mentioned above.

这篇关于具有单独.xib的两个目标(具有相同名称的图像资源)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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