标签:
(1)在VisitorView.swift文件中,懒加载一个按钮:
private var loginButton:UIButton={
let btn=UIButton()
btn.setTitle("注册", forState: UIControlState.Normal)
btn.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
btn.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
// 注册监听
btn.addTarget(self, action: "registerBtnClick", forControlEvents: UIControlEvents.TouchUpInside)
return btn
}()
运行报错:
Cannot convert value of type ‘NSObject -> () -> VisitorView‘ to expected argument type ‘AnyObject?‘
报错图片:
找了半天,终于发现是忘记加关键字"lazy",改为
private lazy var loginButton:UIButton
(2)
标签:
原文地址:http://www.cnblogs.com/sugeladi/p/5196715.html