有点奇怪,但我似乎无法为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
}
}
我需要委托,以便我可以观察子视图的生命周期。
答案 0 :(得分:1)
UIView
没有(并且从未有过)名为delegate
的属性。
这就是您收到此错误的原因。
您确定不应该使用自己编写的UIView
自定义子类吗?
如果没有,为什么要设置delegate
的{{1}}。你真正想做的是什么?