IBOutlet和IBAction [英] IBOutlet and IBAction

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

问题描述

在iPhone的Objective-C编码中使用IBAction和IBOutlet的目的是什么,如果我不使用它会有什么不同吗?

What is the purpose of using IBAction and IBOutlet in Objective-C coding for the iPhone, does it make any difference if I don't use them?

推荐答案

IBAction IBOutlet 是定义的宏,用于表示可以引用的变量和方法在Interface Builder中。

IBAction and IBOutlet are macros defined to denote variables and methods that can be referred to in Interface Builder.

IBAction 解析为 void IBOutlet 解析为空,但它们向Xcode和Interface构建器表示可以在接口构建器中使用这些变量和方法将UI元素链接到您的代码。

IBAction resolves to void and IBOutlet resolves to nothing, but they signify to Xcode and Interface builder that these variables and methods can be used in Interface builder to link UI elements to your code.

如果您根本不打算使用Interface Builder,那么您的代码中不需要它们,但如果您要使用它,那么您需要指定 IBAction 表示将在IB中使用的方法, IBOutlet 表示将在IB中使用的对象。

If you're not going to be using Interface Builder at all, then you don't need them in your code, but if you are going to use it, then you need to specify IBAction for methods that will be used in IB and IBOutlet for objects that will be used in IB.

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

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