覆盖Swift中的属性

时间:2017-12-28 15:07:15

标签: swift inheritance override

我有一个类似下面的课程

 class MainVC: UIViewController {

   lazy var someBtn: UIButton = {
    let button = UIButton(type: .system)
    button.translatesAutoresizingMaskIntoConstraints = false
    button.isHidden = true
    button.addTarget(self, action: #selector(didPressBtn), for: .touchUpInside)
    return button
   }()
 }

我将MainVC子类化,当我尝试覆盖someBtn时,错误消息显示为Getter for 'someBtn' with Objective-C selector 'someBtn' conflicts with getter for 'someBtn' from superclass 'MainVC' with the same Objective-C selector

class SecondVC: MainVC {
   override var someBtn:UIButton = {
      return UIButton()
   }
}

0 个答案:

没有答案