2

Alright, I have tried protocols (see Swift: collectionviewHeader delegate not working?) but I am now attempting a simpler approach to call a function from another class, but no matter what I do I get a SIGABRT error.

I have my main view controller which is a MSMessagesAppViewController, and I have a collection view in my storyboard. The header cell from the storyboard has a separate class called HeaderCollectionReusableView. I need to call a function that animates a change in the size of the header cell, meaning a func in the header class.

This is where I create the header cell in my main class:

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {

    let headerView: HeaderCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell", for: indexPath as IndexPath) as! HeaderCollectionReusableView

    //header1 = headerView //here I tried to set the view to a variable

    return headerView
}

What I have tried to do is store this header in a class wide variable so that I can call a function that is in its class. Problem is By doing something like this:

var header1 = UICollectionReusableView()

then in the above function setting header1 = headerView as! UICollectionReusableView gives the error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout attributes for supplementary item at index path

Or making the variable

var header1 = HeaderCollectionReusableView()

Does this:

Failed to inherit CoreMedia permissions from 3835: (null) 2017-01-31 20:02:31.442 MessagesExtension[3836:1672474] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN:

Is this impossible? How can I call a function in my header cell class?

Community
  • 1
  • 1
blue
  • 7,175
  • 16
  • 81
  • 179

0 Answers0