SWRevealViewController panGestureRecognizer with UIScreenEdgeGestureRecognizer - ios

I've been looking for solution for this question,but didnt find any one. So I use SWRevealViewController for sidebar menu in my project but I want that side menu would open when user beging to touch from left edge of the view. I want this because I have another swipeGestureRecognizer for left and right swipe.For adding left and right swipes I'm use this code:
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:#selector(swipedToRight:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget: self action: #selector(swipedToLeft:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
So my question is how can I make that side menu would open only when touches begins from left edge?
UPD 1
I use this code to open side menu by panning at any part of the screen
[self.view addGestureRecognizer: self.revealViewController.panGestureRecognizer];
And I have recognizer to swipe to right. The problem is once it open menu and once executes swipe's action. I want to allow to open menu only when touches is from left edge
UPD 2 Solved
I solved it by setting draggable border width:
self.revealViewController.draggableBorderWidth = self.view.frame.size.width / 2;
And now gesture from edge to center opens menu, and from center to right border executes swipe's action

What I would do is modify the already existent pop gesture that is built into the UINavigationController class.

You can add a UIPanGestureRecognizer as you mentioned before or add a subView in the top of your view and add a gesture to it:
UIView *topView = ...
[self.view addSubview: topView];
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:#selector(didPan:)];
[topView addGestureRecognizer:pan];

What I would do is modify the already existent pop gesture that is built into the UINavigationController class.
Example code to add to your viewWillAppear:
if ([self.navigationController respondsToSelector:#selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
// Your code here
}

Related

disable swipe gesture for iCarousel

I am using iCarousel to display an array of images and I want to disable the swipe gesture. I did not find that in the documentation. not sure if this is doable or not
If you want to disable the swipe gesture then I think are you want to do something like programatically change the image.
For very simply disable the user interaction of carousel.
If you using storyboard then simple remove checkmark of User Inreaction Enabled
If you use by code then following code to disable the User Inreaction Enabled
yourcarousel.userInteractionEnabled = FALSE;
May this help lot to solve your problem.
#Junchao GU If you are Using
https://github.com/nicklockwood/iCarousel
They are using Tap gesture and pan gesture
You have to Comment
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:#selector(didPan:)];
panGesture.delegate = (id <UIGestureRecognizerDelegate>)self;
[_contentView addGestureRecognizer:panGesture];
//add tap gesture recogniser
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(didTap:)];
tapGesture.delegate = (id <UIGestureRecognizerDelegate>)self;
[_contentView addGestureRecognizer:tapGesture];
in iCarousel.m File
I hope this will help you
It's bad idea to change source code of iCarousel. I think it's better to do next:
carouselView.contentView.gestureRecognizers?.removeAll()
Hope it helps to someone

Add vertical swipe to UIPageViewController

I have a horizontal swipe of my UIPageViewController that moves between 3 view controllers. I want to add a Vertical swipe onto this to add a extra level to the navigation.
However I have not found a solution to do so. I have tried adding a simple
UISwipeGestureRecognizer *gestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipeHandler:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[self.view addGestureRecognizer:gestureRecognizer];
But this doesn't work as I presume the UIPageView overrides this.
Is there any solution?
If you are doing with storyboards,this tutorial would be helpful
http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/
I am using pageview controller in my app. I have added same code as yours. and my swipe up event is working fine.
change this line in your code
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];

iOS how to detect swipe left or right on UICollectionView that otherwise only scrolls vertically?

My collection view is working great. It shows a grid of photos and lists hundreds of them. You can swipe vertically to scroll through them all. Life is good. However, I now have a new requirement. I need to be able to detect when the user is swiping left or right. I need to be able to intercept this gesture so I can attach behavior to left and right swipes while keeping intact my collection view's vertical scroll capabilities. Any ideas?
You need two recognizers, one for swiping left, and the other for swiping right:
UISwipeGestureRecognizer* swipeUpGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(handleSwipeLeftFrom:)];
swipeUpGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
and for the handler:
- (void)handleSwipeLeftFrom:(UIGestureRecognizer*)recognizer {
}
Finally, you add it to your view:
[view addGestureRecognizer:swipeUpGestureRecognizer];
The same for the other direction (just change all the Lefts to Rights).
add UISwipeGestureRecognizer to the cells settings its direction as below,
UISwipeGestureRecognizer *swipeRightDir = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(didSwipeRightDirection:)];
swipeRightDir.delegate = self;
swipeRightDir.numberOfTouchesRequired = 1;
[swipeRightDir setDirection:UISwipeGestureRecognizerDirectionRight];

IOS: Detect swipe gestures in a specific place on a UIView

I am creating a storyboard app where the view is changed when the user performs swipe gestures. The issue I am having is that when you drag and drop a gesture recognizer onto the view from themain.storyboard file, the gesture is recognized from anywhere inside the UIView. Basically, I need to recognize a gesture that is performed in a specific area on the screen, similar to how you drag down the notification center in IOS 6. If this is unclear or you need more details, feel free to ask.
Thanks in advance for any help!
I am not sure if this will help you or you tried something like this, but i want to share my idea.
You can try UISwipeGestureRecognizer in your ViewControl.m like below:
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipeToDoMethod)];
[swipeGesture setDirection:UISwipeGestureRecognizerDirectionRight];
[[self innerView] addGestureRecognizer: swipeGesture];
You can add an inner view into your main view and add this gesture to that view.
Hope this helps you, good luck! :)
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(SwipeView)];
[swipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[[self innerView] addGestureRecognizer: swipe];
//UISwipeGestureRecognizerDirectionRight (or) up (or) down
Use another UIView with 0 visibility, put it on area where you want recognize a gesture and then add gesture to this UIView.
This is just an idea.
Hope this will help you.
You can add a subview into your view, set the subview's frame to the area where you want to catch the swipe gesture, add recognizer to it, and set its background color to clear color. Hope it help.
Adding Swift version:
//Add gesture recognizer
let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(dismissShowMessageAndButtonDueToSwipeUp))
swipeGesture.direction = .up
backgroundView.addGestureRecognizer(swipeGesture)

iOS working with multiple swipe recognizers

I have right and left swipe recognizers on my view, as well as a table.There is a problem when user swipes left->right on the table view, table handle them and swipes table content instead of execution of left->right swipe recognizer methods. How do I increase the sensitivity of left->right swipe recognizers?
Here's the code for the recognizers:
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipeRight)];
swipeRecognizer.numberOfTouchesRequired = 1;
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRecognizer];
UISwipeGestureRecognizer *swipeRecognizer1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipeLeft)];
swipeRecognizer1.direction = UISwipeGestureRecognizerDirectionLeft;
swipeRecognizer1.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeRecognizer1];
You can require one gestureRecognizer to fail before another one is invoked.
[lowerPriorityGestureRecognizer requireGestureRecognizerToFail:higherPriorityGestureRecognizer];
It would help greatly if you let us know whether the view is in/over/under the table rather than saying you have both a view and a table. That matters, alot.

Resources