Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use interactivepopgesturerecognizer with CollectionView with horizontal scroll when navigation bar is hidden

i'm trying to use the interactivepopgesturerecognizer to go back in a view in which i have also a UICollectionView with horizontal scrolling, and the problem is that in the frame of the collection view the swipe to go back doesn't work, but works when the touch begin out of the frame of the collection view, this is an example of my view:

| ---> here works
|-----------
|
| ---> This is the collection view and doesn't swipe to go back
|
|-----------
| ---> here works

how i can solve the problem?

EDIT: i realized that this problem occurs only when in the pushed view the nav bar is hidden, and when is hidden the swipe to go back doesn't work in all view not only in the collection view, and to make it work i need to add this line:

[self.navigationController.interactivePopGestureRecognizer setDelegate:nil];

in the main view, but in this way i can't swipe to go back in the collection view. i have created a simple test to check the problem:

https://www.dropbox.com/s/c7ueyrcmm2x1m5w/TestSwipe.zip?dl=0

like image 408
Piero Avatar asked Jan 21 '15 20:01

Piero


1 Answers

Add this line of code to your viewDidLoad method in your SecondViewController

[self.collectionView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];

This essentially tells the collection view's gesture recognizer that it needs to wait for the interactive pop recognizer to fail before proceeding, forcing the interactive pop to be prioritized.

like image 123
SomeGuy Avatar answered Oct 27 '22 13:10

SomeGuy