如何解决此错误?- 类“ViewController"没有初始值设定项 [英] How to resolve this error? - Class 'ViewController' has no initializers
本文介绍了如何解决此错误?- 类“ViewController"没有初始值设定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在 swift 中以编程方式创建了 UILabel
但它给了我以下错误:
I have created UILabel
programmatically in swift but it gives me following error :
ViewController"类没有初始化器
Class 'ViewController' has no initializers
代码:
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)
}
}
推荐答案
将 let lbl_LastName: UILabel!
更改为 var lbl_LastName: UILabel!
这篇关于如何解决此错误?- 类“ViewController"没有初始值设定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文