如何使用 Xcode 4 重构大型 xib 文件?

发布于 2025-01-06 20:24:16 字数 278 浏览 5 评论 0原文

我们有一个大型应用程序,有 21 个视图控制器 - 全部位于一个 xib 中。我们希望将其重构为单独的 xib 文件 - 每个视图控制器一个。我在 Xcode 4 中没有看到任何明显的方法可以做到这一点。这可能吗还是我必须从头开始?

(在这里回答我自己的问题...)

啊哈! (尤里卡)

如果我打开第二个 xcode 窗口(文件 -> 新建 -> 窗口)并创建一个空的 .xib 文件,我可以将对象从主 xcode 窗口中的 xib 拖动到新 xcode 窗口中的空 xib 中!

We have a large application that has 21 view controllers - all in a single xib. We'd like to refactor this into individual xib files - one per view controller. I don't see any obvious way to do this in Xcode 4. Is this possible or do I have to start from scratch?

(Answering my own question here...)

Ahah! (Eureka)

If I open a second xcode window (File->New->Window) and create an empty .xib file, I can drag objects from the xib in the main xcode window into the empty xib in my new xcode window!

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

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

发布评论

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

评论(1

呆萌少年 2025-01-13 20:24:16

您可以将视图从大 XIB 复制并粘贴到新 XIB 中,但没有自动执行此操作的方法。我的意思是选择每个视图控制器的根视图,并将其粘贴到您将为每个视图控制器创建的新 XIB 中。

不过,我不太确定您是如何设法将 21 个视图控制器放入单个 XIB 中的。只有一个“文件所有者”。我想你可能有多个视图控制器,最终由单个文件的所有者拥有,但这是一种非常奇怪的做事方式。我建议你尽快搬走(我确信你问这个问题就是这么做的!),生活会变得简单得多。

You could copy and paste the views out of the big XIB and into new XIBs, but there's no automated way of doing that. By that I mean select the root view of each view controller, and paste it into the fresh XIB you'll create for each view controller.

I'm not really sure how you've managed to get 21 view controllers into a single XIB, though. There's only one "File's Owner". I suppose you could have multiple view controllers in there that end up being owned by the single file's owner, but it's a very strange way to do things. I suggest you move away ASAP (which I'm sure you're doing by asking this question!) and life will become a lot simpler.

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