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

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.

Related

Two Swipe Gesture Recognizer on ViewController, only one works?

I have two Swipe Gesture Recognizers on my ViewController. One works fine, when I swipe right it goes back to the previous View. However, the recent one I added doesn't work at all. I have set it to go to a different View Controller when I swipe left but, nothing happens. I didn't add any code for the first Swipe Gesture Recognizer so shouldn't this additional one also be able to work without code?
It goes back because the interactivePopGestureRecognizer handles that, not your swipe recognizer.
You need to do two things:
Wire your gesture recognizers to IBAction calls within your view controller so that it can handle them
Disable the pop gesture recognizer so that it will not conflict with your desired behavior (See answer here for how)

I need help on UIScrollView and when tapping on it to do something

I made a ScrollView and I put a UIButton on the ScrollView so I can go back on the Initial ViewController. But I want it so when I go on the UIScrollView and tap on the screen ,my button will popup from the top. I don't want it to be a SwipeGesture: I just want that when I tap it down, it will popup.
I'm using Xcode Swift
Have you tried to bind UIPanGestureRecognizer with a selector that has:
animateWithDuration(delay:, options:, animations:, completion:)
to visual/hide/move your button.

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.

Activate Pan Gesture on MenuController using ECSlidingViewController

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.

How to detect swipe gesture in a tiny view?

I already know how to attach a swipe gesture to view.
Suppose I have a tiny view (0,0,5,5).When I swipe in it, the action with that gesture is not trigger. Then I debugged, I found out the tap event I attached with this view interfere the swipe. How can I make the swipe action trigger with that tiny view?
Summary, with a same view, if it's tiny - the Tap gesture will handle the action. If it's bigger, the swipe gesture will handle it.

Resources