有点奇怪,但是我似乎无法为UIView
对象设置委托。那个财产去哪儿了?
class ViewController: UIViewController {
// Properties
var subView: UIView!
var subSubView: UIView!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
println("init(coder aDecoder: NSCoder)")
subView = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
subSubView = UIView(frame: CGRect(x: 10, y: 10, width: 80, height: 80))
subView.backgroundColor = UIColor.redColor()
subSubView.backgroundColor = UIColor.blueColor()
subView.delegate = self // Error
subSubView.delegate = self // Error
}
}
我需要代表,以便可以观察子视图的生命周期。
UIView
没有(也从未有过)名为的属性delegate
。
这就是为什么您会收到此错误的原因。
您确定不应该使用UIView
自己编写的自定义子类吗?
如果不是,为什么你想设置delegate
的UIView
。您实际上想做什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句