我试图将目标添加到UICollectionViewCell内的按钮。但是我想在UICollectionViewController中添加目标。我已将按钮设置为惰性var,但仍然无法正常工作。
override func viewDidLoad() {
super.viewDidLoad()
collectionView.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
collectionView.register(ProfileHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerId)
collectionView.register(ProfileCell.self, forCellWithReuseIdentifier: cellId)
let profileHeader = ProfileHeader()
profileHeader.addOfferButton.addTarget(self, action: #selector(handleAddOffer), for: .touchUpInside)
}
@objc func handleAddOffer() {
print(123)
}