[大家好,我需要在UICollectionViewCell
自定义类中添加2个观察者。我以这种方式实现了两个观察者]
override init(frame: CGRect) { super.init(frame: frame) NotificationCenter.default.addObserver(self, selector: #selector(disablePreviousMinutes), name: NSNotification.Name(rawValue: "NotificationIdentifier"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(enableMinute), name: NSNotification.Name(rawValue: "NotificationIdentifier2"), object: nil) }
现在,我想知道如何从
UICollectionViewCell
类中删除观察者
我尝试调用override func willMove(toWindow newWindow: UIWindow?)
,但是这样所有单元格都重复了所有插入的函数
从UICollectionViewCell
自定义类中删除观察者的最佳方法是什么?
[大家好,我需要在UICollectionViewCell自定义类中添加2个观察者。我以这种方式实现了两个观察者,它们覆盖了init(frame:CGRect){super.init(frame:frame)...
只需简短撰写,您就可以将此问题标记为已解决。