IBOutlet在objective-c [英] IBOutlet in objective-c

查看:171
本文介绍了IBOutlet在objective-c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这行代码是做什么的:

IBOutlet UITextField * userName;

推荐答案

也许比changelog更详细一些,但主要发布只是因为我已经打字了,它可能会有帮助,它不会正确格式化不是因为我不同意他的回答:

Maybe a little more detailed than changelog, but primarily posting just because I'd already typed it, it may help and it wouldn't format correctly as a comment, not because I disagree with his answer:

IBOutlet 是代码中的无操作。因此,声明一个实例变量类型 UITextField * 和名称 userName ,就像你刚才键入:

IBOutlet is a no-op in code terms. So that declares an instance variable of type UITextField * and with name userName, exactly as if you'd typed just:

UITextField *userName;

IBOutlet做的是将成员变量标记为在Interface Builder中用作插座因此IB)。因此,当Interface Builder(或Xcode 4,因为两个现在集成)解析你的类定义,它知道要暴露userName作为可以连接到控件的东西。

What IBOutlet does is flag that member variable up as intended to be used as an outlet in Interface Builder (hence the IB). So when Interface Builder (or Xcode 4, since the two are now integrated) parses your class definition it knows to expose userName as something you can connect to a control.

这篇关于IBOutlet在objective-c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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