是否可以在不使用Interface Builder的情况下构建iphone视图? [英] Is it possible to build an iphone view WITHOUT using Interface Builder?

查看:59
本文介绍了是否可以在不使用Interface Builder的情况下构建iphone视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,Interface Builder可以节省时间,但是如果我想在没有它的情况下怎么办?在C#中,所有生成的代码都是清晰易懂的,在界面生成器中,这是隐藏的,因此我至少希望在学习阶段从头做起:任何示例代码都可以这样做?

So Interface Builder does things to save time but what if I want to do without it ? In C# all code generated is clear and understandable, in interface builder this is hidden so I'd like at least during learning phase do things from scratch: any sample code to do so ?

似乎Apple使事情变得非常艰难,因此您无法轻松地使用Xcode的替代品:)

Seems Apple makes things very hard so as you cannot easily use alternative to Xcode :)

http://cocoawithlove.com/2009/02/interprocess-communication -snooping.html

推荐答案

是的,您可以在不使用IB的情况下构建视图.只需分配和初始化视图或控件并设置其属性即可,例如:

Yes, you can build a view without IB. Just allocate and initialize a view or a control and set its properties, e.g.:

UITextField *tf= [[UITextField alloc] initWithFrame: CGRectMake(24.5, 65, 270, 30)];
tf.delegate = self;
tf.textAlignment = UITextAlignmentCenter;
tf.autocorrectionType = UITextAutocorrectionTypeNo;
tf.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self.view addSubview: tf];

但是IB不会隐藏从您那里生成的任何代码,因为它根本不会生成任何代码.而是创建对象实例并将其序列化为XIB或NIB文件.

But IB does not hide any generated code from you because it doesn't generate any code at all. Instead, it creates object instances and serializes them into a XIB or NIB file.

这篇关于是否可以在不使用Interface Builder的情况下构建iphone视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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