0
votes

ListViewController-> DetailsViewController, the navigationController of the DetailsViewController support interactivePopGestureRecognizer feature, that can swipe right and back to ListViewContorller, it is fine,

just the DetailsViewController contains some UICollectionView, it does not response the swipe gesture, it is meaning if user touch the CollectionView swipe,drag the view from left to right, the navigationController not got the action at all, how to solve this problem ?

I just try this way:

[collectionView addGestureRecognizer:  self.navigationController.interactivePopGestureRecognizer];

but it not works .

so then I create new 'Swipe Gesture Recognaizer' and bind to collectionView, also link to the selector action as bellow:

I add code in the details view:

-(IBAction)swipeBack:(id)sender
{
    [self.navigationController popToRootViewControllerAnimated:true];

}

then, if user touch the collectionView, then it can back to list view controller, but it not is good enough, because it not works the same to 'interactivePopGestureRecognizer',

anyone know other best solution for this purpose ? thanks for your time.

1

1 Answers

0
votes

Like it is mentioned in https://stackoverflow.com/a/18947952/1113407 multiple gesture work better if

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

is set.

If that is not enough, try adopting https://stackoverflow.com/a/2628777/1113407 for your needs.

In UINavigationContoller swipe back function not working if its view is added to UIViewContoller "Mr.1" mentioned:

Updated: It turns out that if the navigation bar is hidden, the swipe function will be disabled....

Did you hide the navigation bar?