How to resolve this error? - Class 'ViewController' has no initializers

六月ゝ 毕业季﹏ 提交于 2020-01-02 08:18:13

问题


I have created UILabel programmatically in swift but it gives me following error :

Class 'ViewController' has no initializers

Code :

class ViewController: UIViewController {

    let lbl_LastName: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        lbl_LastName.frame = CGRectMake(10, 230, 300, 21)
        self.view.addSubview(lbl_LastName)   
    }
}

回答1:


change let lbl_LastName: UILabel! to var lbl_LastName: UILabel!



来源:https://stackoverflow.com/questions/31780647/how-to-resolve-this-error-class-viewcontroller-has-no-initializers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!