I have a class for my UICollectionReusableView, but I need a button in that view to perform a segue from the UICollectionView to an imagePicker. I have tried to use a delegate, but I keep on getting nil for the delegate.
protocol ShouldSegueToImagePickerDelegate{
func shouldSegue()
}
class ProfileHeaderCollectionReusableView: UICollectionReusableView{
var delegate: ShouldSegueToImagePickerDelegate!
@IBAction func pressedChangeBGPicButton(sender: AnyObject) {
delegate.shouldSegue()
}
class ProfileCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout, ShouldSegueToImagePickerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate{
var imagePicker = UIImagePickerController()
func shouldSegue() {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
self.presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
imagePicker.dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
imagePicker.dismissViewControllerAnimated(true, completion: nil)
}