When I press the edit button located in the Header View nothing happens, the button is just not selectable and I'm not sure why.
The custom UICollectionReusableView with the edit UIButton and the button function.
class headerView: UICollectionReusableView {
var editProfile = UIButton()
func editBtnPressed(_ sender: UIButton) {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : editVC = storyboard.instantiateViewController(withIdentifier: "search") as! editVC
let navigationController = UINavigationController(rootViewController: vc)
}
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(editProfile)
editProfile.translatesAutoresizingMaskIntoConstraints = false
}
}
The UICollectionViewController that calls the edit UIButton function.
class homeVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
//define header
let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "Header", for: indexPath) as! headerView
header.awakeFromNib()
header.editBtn = editBtnPressed
header.editProfile.addTarget(self, action: #selector(headerView.editBtnPressed(_:)), for: .touchUpInside)
}
}