Activate Pan Gesture on MenuController using ECSlidingViewController - ios

I'm currently using ECSlidingViewController in my app. As default behaviour, it's possible to show the side menu (MenuViewController or underRightViewController) panning on the top view or calling the RevealMenu: method.
I extended this functionality giving the user the possibility to pan the top view controller back adding this line to the UnderLeftViewController ViewDidLoad method:
self.slidingViewController.shouldAllowUserInteractionsWhenAnchored = YES;
(source here)
Here the limitations:
User must touch the top view on the side to pan it back,touching the MenuController cell won't have any effect. If you look at the Facebook iOS you will notice it's possible to pan the top view starting the gesture in the middle of the side tableviews.
adding the above line of code will disable the TapRecogniser previously active on the top view (and I would need it to work at the same time of the Pan recogniser).
Does anybody know how to implement this behavior?

Ok, I might have found a work around for the tap recogniser problem, instead of the previous line insert this one in your side menu view controller
self.slidingViewController.shouldAddPanGestureRecognizerToTopViewSnapshot = YES;
still it's not possible to swipe on the menu view though,but at least I have swipe and tap events working on the top view once is on the side.

Related

How to Swipe Away / Slide In a Side Menu In Swift?

In my app I've coded a side menu that looks like this:
Here's the code that is called when I tap a menu button that's in some views:
How can I have the menu slide in to view (depending on where the user's dragging finger is) and swipe away? And also go away when I tap the dimmed view on the right.
Any help is appreciated.
One way to achieve this is using the gesture recognizers in swift.
To tap and dismiss the menu control, use UITapGestureRecognizer, bind it with a selector method and dismiss the controller/ view you are presenting. Check out the link to apple documentation for TapGesture : Guide
For swipe gesture, add Swipe gesture UISwipeGestureRecognizer to the UIView, and write the dismiss method using slide animation for smooth UI. Swipe Gesture Guide
Let me know if you need any more help.

Default interactivePopGestureRecognizer from anywhere on screen

The default interactivePopGestureRecognizer only works if you swipe left to right on the left edge of the screen. I would like to be able to perform this gesture by swiping anywhere on my screen. Apps like Reddit, Slack and Twitter have implemented this gesture, so I know it is possible.
So far, I have successfully popped to the previous VC using a swipe gesture self.navigationController.popViewControllerAnimated(true), however it does not show the top stack during the swipe. This action performs an immediate and quick animated transition to the other stack. I would like the animation to be similar to the default and slowly "peel away" the stack as the finger is dragged across the screen. This leads me to believe that it is possible to do this with a pan Gesture, however I am unsure how to slowly move the current view controller out of the frame and reveal the next stack during translation.
EDIT: SOLUTION
Here is the solution: https://stackoverflow.com/a/35510861/9159691
I think this is easier than the suggested solution and also works for all viewControllers inside that navigation and also for nested scrollviews.
https://stackoverflow.com/a/58779146/8517882
Just install the pod and then use EZNavigationController instead of UINavigationController to have this behavior on all view controllers inside that navigation controller.

Swift: UIPageViewController - Navigate view controllers with swipe from edge of screen

I am new to UIPageViewControllers and can't seem to find a solution elsewhere. I have a working UIPageViewController with 3 different viewControllers. Right now you can navigate to a different viewController by swiping left or right starting at any point on the screen. However, I only want to navigate to a different viewController when I swipe over from the right or left edge of the screen. Similar to how the Screen Edge Pan Gesture works. Is this possible? If so, how would I go about implementing this in my program.
What I do in this situation is to attach gesture recognizers to the views of the "3 different viewControllers", that is, the child view controllers of the page view controller. These gesture recognizers' action methods post notifications. In the view controller that controls the page view controller, I receive these notifications and call setViewControllers:direction:animated: to perform the appropriate slide.
UIPageViewController has and embedded gesture recognizers that to the trick. Normally you have no influence on them. You could get to them by calling gestureRecognizers method on UIPageViewController's view and see what you can do with them from there.

Swift: Navigate ViewControllers with UIPageController or Screen Edge Pan Gesture Recognizer

I have 4 ViewControllers that I want to navigate through by swiping left and right from the edge of the screen. I am fairly new to ios, so was just wondering if it would be more beneficial to activate a segue by using a Screen Edge Pan Gesture Recognizer or by using a UIPageViewController. It is worth noting that the ViewControllers all contain gesture recognizers, imageViews, textViews' etc. I do only want to switchviewControllers` when swiped from the edge of the screen.
If you use edge swipe gesture recognizer, you're going to have to write code to manage the view controllers. If you're new to iOS, I might suggest using the page view controller, so it gets you out of the weeds of managing this yourself.
Both can work, but I'd suggest starting with the page view controller and only "roll your own" if the page view controller doesn't give you the control that you need.

GestureRecogniser not working when going back

I am using SWRevealController class to add a sidebar. This adds a gesture recogniser for a swipe.
I have a table with a few choices and initially the swipe works fine. However, if I select a choice, go to the new page and then come back via the nav, the swipe STOPS working (however the button for the sidebar still works).
This is the code for the swipe added to viewDidLoad
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
What do I need to do to fix it?
Call [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer]; in viewWillAppear instead of viewDidLoad so that it is replaced following each transition. A gesture can only be attached to one view at a time so when you attach it to a different view it gets removed from the first.
Alternatively, consider adding the gesture to a more root view (like the window / navigation bar) depending on what interaction you want to enable.

Resources