How to resolve this error? - Class 'ViewContro

2019-05-15 16:03发布

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

Class 'ViewController' has no initializers

enter image description here

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条回答
▲ chillily
2楼-- · 2019-05-15 16:49

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

查看更多
登录 后发表回答