iOS 13删除UICollectionViewCell自定义类中的Observer

问题描述 投票:0回答:1

[大家好,我需要在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)...

ios swift uicollectionview uicollectionviewcell nsnotificationcenter
1个回答
1
投票

只需简短撰写,您就可以将此问题标记为已解决。

© www.soinside.com 2019 - 2024. All rights reserved.