CAPSPageMenu swipe and side menu swipe conflict in iOS - ios

I'm using CAPSPageMenu (https://github.com/PageMenu/PageMenu) in my app. I have side menu (ECSlidingViewController - https://github.com/ECSlidingViewController/ECSlidingViewController). Now if the side menu is opened I want to disable the swipe gesture of pagemenu and If user swipe the side menu should close. Currently what's happening is if side menu open and the user swipe pagemenu is changing page. How can we acheive this?
Here's the code to disable swipe in page menu
_pagemenu.controllerScrollView.scrollEnabled = NO;
How I tried is I wrote one call back in the side menu tap and I try to reload the pagemenu according to that. But it is not working.
if (self.menuCallBack) {
_pagemenu.controllerScrollView.scrollEnabled = NO;
} else {
_pagemenu.controllerScrollView.scrollEnabled = YES;
}
And how can avoid swipe after last page. I'm having 3 screens. If we swipe after 3rd screen it is showing some blank view how can we avoid this?
Any help could be appreciated. Thanks in advance.

ECSlidingViewController is making use of Pan gesture for detecting the horizontal swipe. CAPS pagemenu uses scrollview. The ECSlidingViewController must not be receiving the gesture, even if scrollview is disabled on CAPSPageMenu class.
Try this code on your CAPSPagemenu class:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

Related

Horizontal uitableview with screen edge swipe gesture

I have a view which looks like this:
I implemented this view with two horizontal uitableview. So all promotions under certain category actually is in a table view which allow user to swipe left and right to change category. On the left top there is a button which opens a side view. Now I want to add a screen edge gesture to open the side view but it seems the screen edge gesture conflicts with the table view scrolling gesture.
So where should I do if I want to implement the screen edge gesture without disabling tableview's scroll gesture?
Thanks!
Set your gesture delegate in your viewcontroller class, and use this delegate method :
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES ;
}

ios,How to preform (interactivePopGestureRecognizer )back action in Collection view

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.
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?

iOS gesture collisions between slider and pan gesture on controller

I am using ECSlidingViewController for hamburger menu and I added code to my viewDidLoad method:
[self.slidingViewController.topViewController.view addGestureRecognizer:self.slidingViewController.panGesture];
Now I have pan gesture to show right menu or to hide. It's okay. But I have on view slider and it's really hard to get him working. I must tap on exact position. Is it possible to set that in exact rectangle (in view that contains slider) the slider would be answering on gesture and on other parts it would be working as now?
And one more question. When I have navigation controller with table and then I went on detail and then I show right menu it's okay but when I want to close it by pan I first go back in navigation and then close menu. Is it possible to change this order?
Have you tried setting UIGestureRecognizerDelegate and handling the both gesture recognizes in similar fashion as described in FAO?
e.g.:
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([otherGestureRecognizer.view isKindOfClass:[UISlider class]]) {
return YES;
} else {
return NO;
}
}

Remove Gesture for view while Sliding Menu Activated

i'm using ECSlidingViewController and i've a problem when using pan Gesture to open the sliding menu the tableview in the main view still have the scrolling gesture
i need to remove the gesture of the main view and add it back when it slide back
in the InitViewController add the following method
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return NO;
}
if return YES it will make the undesirable behavior

iPad - PageViewController - Show next view controller on button click

I'm using UIPageViewController in my application that shows all the images similar to a book. Its working fine.
What I want to do now:
I want to place a button on top left corner and on click it will show a pop over view controller which has a table view with 7 cells. Each cell will show different URL. On click of the table cell, it will push a view controller with web view.
What's the problem
The problem is that I placed the button on top left and created a segue to show popover. But on click of button it goes to previous page and on next clicks it will finally reach page 1. then in page 1, it will show the pop over. I didn't understand why is it happening like this.
And even after showing popover, its not showing next view with website.
How to do it?
The trick is that UIPageViewController's gesture recognizers take over that area. In particular, the tap handler; so your button only gets hit when the tap recognizer does not take it as meaning to go to the previous page.
Quickest solution is to set yourself to the delegate of its recognizers
for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers)
recognizer.delegate = self;
and then implement the delegate telling them to let controls get touches
- (BOOL)gestureRecognizer:(UIGestureRecognizer *) __unused gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UIControl class]])
return NO;
return YES;
}
which ought to sort you nicely.

Resources