如何使用IBOutlet子类化变量? [英] How do I subclass a variable with an IBOutlet?

查看:91
本文介绍了如何使用IBOutlet子类化变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的特定类的所有后代都有一个 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子类化变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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