Accessing parent from UICollectionViewCell

3.1k Views Asked by At

I have a UIView (it's actually a PM::Screen) and am adding a subView which is a UICollectionViewController's view. I'm using this technique to switch between things like grid/list ala the Instagram profile screen.

Selecting a cell should open a new screen, which I want to push on to the parent view's (the PM::Screen) navigation controller.

My question is how do I get the collectionView(view, didSelectItemAtIndexPath: index_path) to call a method on the parent PM screen?

Will I have to use NSNotificationCenter?

1

There are 1 best solutions below

1
On

I have managed with:

self.view.superview.nextResponder.theMethodToCall

Is there a better way?

UPDATE:

I ended up passing a reference to the parent to the child, and using that reference to call the method on the parent