开发者

Can I define a UIView both in a nib AND programmatically?

开发者 https://www.devze.com 2023-03-18 08:02 出处:网络
Is this common practice or frowned upon?Are there any standards/reso开发者_开发问答urces for such a practice?What are the alternatives?I realize the question is broad, but I am new to iOS development

Is this common practice or frowned upon? Are there any standards/reso开发者_开发问答urces for such a practice? What are the alternatives? I realize the question is broad, but I am new to iOS development and any information helps. Thanks!

EDIT: I do mean the same view.


Yes, you can interchange XIB-described objects with program-created ones, and you can do programed modifications of an XIB-instantiated object, or you can use an XIB-instantiated object inside a programmed view.

Basically an XIB just "generates code" (in a backwards sort of way) to instantiate the objects it describes, and once the root view and all of its subviews are created it's indistinguishable from its program-created twin.


Yes, you can mix use of programmatically created and nib loaded resources in any way you like - often the nib will be used to set up a skeleton that code might alter or add more views to.

0

精彩评论

暂无评论...
验证码 换一张
取 消