我经常不能正确 Split View和 Controller 相关的东西。
如果我想在我的应用程序中自定义 uibutton 和背景并在我的 View 中添加与样式相关的东西,我应该始终将 uiview 子类化,还是应该在我的 Controller 中处理它?或者可能是 uibutton 的子类?
对齐怎么样?我什么时候应该将 uiview 子类化、向其添加按钮然后对齐或在我的 Controller 中处理它?</p>
感谢您的指点! 如果不清楚,请发表评论。
最佳答案
Should i always subclass a uiview if I want custom uibuttons and backgrounds in my app and add style related stuff in my view
如果您的需求是基本的,您可以将需要的元素作为 View 的 subview 插入,而无需子类化任何东西。按钮和 View 有足够的属性来处理这些简单的需求。但一切都取决于这些需求是什么。
Should i handle this in my controller? or probably subclass a uibutton?
为 UIButton 行为子类化 UIButton 不是一个坏主意 :-) 但是如前所述,您需要什么作为特殊行为?一个特殊的图像:有一个属性。对事件的特殊 react ,将其管理到 IBActions 上的 Controller 中。具有 UFO 行为的 UIButton,好的,让我们对其进行子类化。
What about alignings? when should i subclass a uiview, add buttons to it and align then or handle this in my controller?
嗯……我想永远不会。这可以(应该)在 Controller 中完成。 Controller 控制整个 UItems。因此,如果您想将一个项目与另一个项目对齐,请在 Controller 中执行。如果要将显示到按钮中的特殊图形或文本对齐,请将其子类化并在 drawRect
方法中进行管理。
关于iphone - 何时 Split View和 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8057762/