XIB 文件与在 iPhone 中的代码中定义布局

发布于 2024-09-27 11:02:06 字数 139 浏览 0 评论 0原文

除了所见即所得编辑器之外,与在 iPhone/iPad/iOS 中用代码定义布局相比,使用 XIB/NIB 文件有哪些优势?

虽然我认为 XIB 文件没有多大用处,但许多 iOS 开发人员却如此,这让我怀疑我可能不知道它们的好处或如何正确使用它们。

Aside from the WYSIWYG editor, what are the advantages of using XIB/NIB files over defining the layout in code in iPhone/iPad/iOS?

While I don't find XIB files much useful, many iOS developers do, which makes me suspect I might not know their benefits or how to use them properly.

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

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

发布评论

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

评论(3

花开半夏魅人心 2024-10-04 11:02:06
  1. 维护更方便。通常,客户需要最后一刻的更改,例如更改徽标或更改颜色或重新调整某些内容等。在 xib 文件中更改它并立即查看/显示结果要容易得多
  2. 。它迫使您直接从偏移量编写良好解耦的代码,这又意味着更容易维护。
  1. Easier maintenance. More often than not, clients require last minute changes like changing the logo or changing colors or realigning something or some such. Much easier to change it in a xib file and see/show the results immediately
  2. Decoupling. It forces you to write nicely decoupled code right from the offset, which again means easier maintenance.
静赏你的温柔 2024-10-04 11:02:06

在 Interface Builder 中定义事物可以让以后更容易调整。此外,在代码中处理界面元素可能会导致大量代码膨胀,用于设置精确位置、字体、颜色等。

直接使用代码的主要优势是速度。但通常最好从 IB 开始,然后看看哪些内容可能需要加速。

表格单元格是您可能考虑在代码中绘制元素以提高速度的主要区域之一。

Defining things in Interface Builder makes them much easier to adjust later. Also, doing interface elements in code can lead to a lot of code bloat, for setting things like exact placement, font, color, etc.

The main advantage using code directly gives you is speed. But it's usually better to start in IB and then see what might need speeding up.

Table cells are one of the main areas where you might consider drawing elements in code for speed.

独留℉清风醉 2024-10-04 11:02:06

就我个人而言,我使用 XIB 以图形方式查看我正在做的事情,因此我不必运行、检查外观、更改一点颜色、运行应用程序、检查...它使我能够获得更好的设计。如果你与为你提供 Photoshop 设计的设计师合作,它对你来说不会有用。

第二件事:当你开始真正处理 Xib 时,它比使用代码要快得多(但例如 TableView 和 tableView cell 需要时间和培训)

Personnaly, I'm using XIB to see graphically my I'm doing so I don't have to run, check the look, change a bit the color, run the app, check... It allows me to get a better design. If you work with designer that gives you photoshop design, it will not be useful for you.

Second thing : when you start to really handle Xib, it's much faster than doing it with code (but it takes time and training for TableView and tableView cell for example)

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