I have a UIView subclassed on a custom collectionView cell. It displays fine but in the "didSelect" delegate method in my ViewController I set a property for the UIView which refreshes with a setNeedsDisplay and drawRect isn't being fired. Does it have anything to do with the dequeueReusableCell? How would that be coded? This is in swift 1.2 not obj-c.
class setSelection: UIView {
private var _checked: Bool = false
override init(frame: CGRect) {
super.init(frame: frame)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setNeedsDisplay()
}
override func drawRect(rect: CGRect) {
super.drawRect(rect)
. . . code . . .
}
var checked: Bool {
get {
return _checked
}
set {
_checked = newValue
self.setNeedsDisplay()
println(_checked)
}
}
This is the UIView class. the checked property is being set in the collectionView didSelectCell. The setNeedsDisplay in the property doesn't fail but drawRect will never be called again.
** UPDATE ** The init functions are not required and should be removed.