Reputation: 17295
A bit bizarre, but I can't seem to set a delegate for UIView
objects. Where did that property go?
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
}
}
I need the delegate so that I can observe the lifecycle of my subviews.
Upvotes: 0
Views: 1163
Reputation: 77631
UIView
doesn't have (and has never had) a property called delegate
.
This is why you're getting this error.
Are you sure you're not supposed to be using a custom subclass of UIView
that you have written?
If not, why are you trying to set the delegate
of a UIView
. What is it you're trying to actually do?
Upvotes: 1