简体   繁体   English

我们可以通过编程方式创建xib(带有视图)吗? 如果否,为什么?如果是,如何?

[英]Can we create xib (with view) programmatically ? If No, why & If yes, How?

Can we create xib (with view) programmatically ? 我们可以通过编程方式创建xib(带有视图)吗? If No, why & If yes, How ?? 如果否,为什么&如果是,如何??

Xibs are just files, too, so there's no technical reason why you wouldn't be able to create one programmatically. Xib也是文件,因此没有技术原因导致您无法以编程方式创建一个。

Expect no convenience methods to create xibs however, as their purpose is to circumvent the need to create and configure UI elements programmatically, so what you would like to do is exactly the opposite of what people normally use xibs for. 但是,期望没有方便的方法来创建xib,因为它们的目的是避免以编程方式创建和配置UI元素的需要,因此您想要做的事情与人们通常使用xib的情况恰好相反。

If you really must create xibs though, just open one in a texteditor - you'll see that it consists of readable xml code. 但是,如果确实必须创建xib,则只需在文本编辑器中打开xib-您将看到它包含可读的xml代码。 It may take some time to work through all the keys and possibilities, but creating xibs programmatically can be done. 完成所有键和可能性可能要花费一些时间,但是可以以编程方式创建xib。

Edit: it's gonna be hard, though. 编辑:虽然会很困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM