用笔尖或代码设计iPhone界面? [英] Designing the iPhone interface in a nib or in code?

查看:98
本文介绍了用笔尖或代码设计iPhone界面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在思考这个问题一段时间......

I've been pondering over this question for a while now...

一方面,Interface Builder提供了一种非常简单的方法来设计界面和用代码中的对象连接元素。

On the one hand, Interface Builder offers a really easy way to design the interface and wire the elements up with objects in code.

另一方面,在较大的项目中,Interface Builder变得很难维护。

On the other hand, in larger projects, Interface Builder becomes a hassle to maintain.

我们将非常感谢任何建议。

Any suggestions would be greatly appreciated.

推荐答案

我曾经非常强烈反对在我自己的界面中使用Interface Builder项目。这是由于许多因素造成的。当iPhone SDK重新开始测试时(2008年3月左右),我开始使用Xcode工具,因为我不是来自Mac Cocoa背景,所以我对使用它有点不熟悉。这不是我最初拒绝用于iPhone开发的IB的主要因素,但在最初的iPhone SDK beta期间,用于iPhone开发的Interface Builder确实很糟糕,并且使用起来很痛苦。

I was once very strongly against using Interface Builder in my own projects. This was due to a number of factors. I started first working with the Xcode tools when the iPhone SDK was back in beta (around March 2008), and since I didn't come from a Mac Cocoa background I was somewhat unfamiliar with using it. This was not the major factor in my initial rejection of IB for iPhone development, though - Interface Builder for iPhone development during the initial iPhone SDK beta did actually suck and it was a pain to use.

然而,这个故事与今天的iPhone SDK有很大的不同。虽然仍有一些烦人的IB漏洞,但我对使用Interface Builder的态度已经接近完成了180˚。我发现,在你的项目中使用Interface Builder通常是个好主意。它现在是一个很棒的工具,你应该利用它。

However, the story is much different with today's iPhone SDK. While there are still certainly some annoying IB bugs, I've done a nearly complete 180˚ with my attitude toward using Interface Builder. More often than not it is a good idea to use Interface Builder in your projects, I've found. It is a great tool now, and you should avail yourself of it.

现在,不要误解我的意思 - 我仍然坚定地认为你在营地里应该能够使用代码单独在Interface Builder中实现任何,我认为能够这样做是非常宝贵的。不要将Interface Builder用作拐杖 - 最终你只会伤害自己(以及你的生产力或产品质量)。虽然IB的拖放效果非常适合您需要做的90%,但是当您有自定义实现的东西只能在代码中完成时,您可能希望您已经关注或感恩遵循这个建议。我很幸运地厌倦了IB足够长的时间,我自学了如何单独用代码完成所有工作,然后将这些知识应用到IB。

Now, don't get me wrong - I am still firmly in the camp that believes that you should be able to implement anything you do in Interface Builder using code alone and I think being able to do so is invaluable. Do not use Interface Builder as a crutch - you'll only hurt yourself (and your productivity or the quality of your products) in the end. While the drag-and-drop niceties of IB are great for 90% of what you'll need to do, when you have something custom to implement that can only be done in code, you'll either wish you had followed or be thankful for following this advice. I was lucky enough to hate IB long enough that I taught myself how to do everything in code alone, and then applied that knowledge back to IB.

编辑:

为了解决NIB与代码缺乏可重用性(感知或真实)的问题......您将不会实现在Interface Builder中大量重用的东西。您无法在IB中真正进行自定义控件或视图,因此排除了这种情况,并且在大多数情况下,您将实现为满足特定目的而构建的视图控制器子类。当然,您应该始终努力使您的代码和相关资源尽可能可重用。这可能包括设计注意事项,以确保您不会不必要地复制非常相似的视图控制器子类。


To address the lack of reusability (perceived or real) with NIBs versus code...you won't be implementing something that is meant to be heavily reused in Interface Builder in all likelihood. You can't really make a custom control or view in IB, so that's ruled out, and in most cases you're going to be implementing a view controller subclass that is built to address a specific purpose. You should of course always strive to make your code and associated resources as reusable as possible. This could include design considerations to ensure that you don't unnecessarily duplicate view controller subclasses that are very similar.

这篇关于用笔尖或代码设计iPhone界面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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