问题描述
我的特定类的所有后代都有一个 UILabel
实例变量。所以在我的父类中,我有 var标签:UILabel
。我想在子类中使用它,但是作为 IBOutlet
。我该怎么做?
All descendants of my specific class are to have a UILabel
instance variable. So in my parent class I have var label: UILabel
. I want to have it in the sublclass as well, but as an IBOutlet
. How do I do this?
我添加了同名的 IBOutlet
,并对两个变量声明添加了弱。但是我收到一个关于无法覆盖存储属性的错误。
I added the IBOutlet
of the same name, and added weak to both variable declarations. But I get an error about "Cannot override with a stored property".
我应该怎么做?是否有可能不必实例化超类'版本,因为我只想将其用于子类化?
How should I be doing this? And is it possible to not have to instantiate the superclass' version as I just want it for subclassing?
推荐答案
只需添加 IBOutlet
超类中的修饰符。
Just add the IBOutlet
modifier in the superclass.
这篇关于如何使用IBOutlet子类化变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!