两个具有单独 .xib 的目标(具有相同名称的图像资源)

发布于 2024-12-27 03:31:40 字数 1197 浏览 6 评论 0原文

我有一个有两个目标的项目,比如说appAappB

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

我还有两组 png,每组对应一个目标。

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

*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 相同)

一切正常,除了当我尝试在 IB 中编辑 .xib 文件时 - 似乎 感到困惑,部分显示来自一个目标的图像,部分显示来自另一个目标的图像。

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

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

我找到了一个快速&肮脏的解决方案。在我开始编辑 .xib 之前 我删除了对另一组 png 的引用。这样IB就会显示正确的图像 对于我正在编辑的 .xib。我只是导入回所有参考文献(其他的png) 目标)当我完成时。

我发现了一个类似的问题< /a> 这并没有得到真正的回答。

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

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

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

I also have two sets of png's each for one target.

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'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)

Everything works fine except when i try to edit .xib files in IB - it seemes to
get confused and show partly images from one target and partly from the other.

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).

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

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.

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

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

发布评论

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

评论(1

紙鸢 2025-01-03 03:31:40

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

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

当您想要编辑一个目标的 .xib 时,您可以删除引用
其他目标的资源 (png)。

然后退出 Xcode 并再次打开项目。 png 将是
正确的(因为 xcode 不保存对错误的引用
眼下)。

完成后 - 重新导入已删除的参考文献(请注意
检查正确的“目标会员资格”)。

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

No answers so far...

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

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

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').

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

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