[英]Will `IBAction`/`IBOutlet` be accessible in the IB when they arent defined on the ViewController?
I am new to Objective-C and iPhone development. 我是Objective-C和iPhone开发的新手。
I have a collection class implementing common UI functionality, eg. 我有一个实现通用UI功能的集合类,例如。 an EditBox for typing a formula, a label where the result is rendered, and, a button for executing the calculation. 一个用于键入公式的EditBox,一个用于显示结果的标签以及一个用于执行计算的按钮。
I want to be able to embed this functionality in various projects. 我希望能够在各种项目中嵌入此功能。 I don't want to generate the UI apriorialy, rather, I want to define a class with IBOutlet
and IBAction
elements, and, to be able to directly link them with whatever UI is implemented by the application (Using the Interface Builder). 我不想先生成UI,而是想定义一个具有IBOutlet
和IBAction
元素的类,并希望将它们直接与应用程序实现的任何UI链接(使用Interface Builder)。
Will IBAction
/ IBOutlet
be accessible in the Interface Builder although they were implemented on a class different than the ViewController ? 尽管IBAction
/ IBOutlet
是在与ViewController不同的类上实现的,但它们是否可以在Interface Builder中访问? Is this use-case possible with 'Objective-C' ? 'Objective-C'是否可以使用这种用例?
Any help will be appreciated. 任何帮助将不胜感激。
yes. 是。 you can instantiate every class in interface builder and then use that 您可以在接口生成器中实例化每个类,然后使用它
eg a Calculator class 例如计算器类
=> drag a NSObject from the palette/library into the left pane of IB and change its class in the inspector to Calculator :) then you can use that =>将NSObject从面板/库中拖动到IB的左窗格中,并将其在检查器中的类更改为Calculator :),然后可以使用该对象
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.