iOS : Swipe Gesture Push in one ViewController? - ios

I want to add two swipe gesture. I did the code, and it's running, my text in the viewcontroller change when i touch the screen.
BUT, i want to add a "effect" when the user wants to slide at the next (or the previous) news, because currently, i'm just changing the text.
i tried to add action in the storyboard, to add push on the swipe with the view.
It's running, but there are two problems :
The push, seems to have a problem, because, when i want to slide on the previous news, the push effect comes right to left. (and not left - right)
I can't only change the contents without touch the navigation bar ? (because when i slide, the navigation bar loose him title, etc..)

If I understood you correctly you might want to use a UIScrollView. This will give you a nice animation.
You need a UIScrollView and add two of your ViewControllers as subviews.
Here are links to some ScollView tutorials:
Are there any good UIScrollView Tutorials on the net?

Pushing on the navigation controller stack is to the right if you want to go back to opposite direction instead of pushing, you should pop like so: [self.navigationController popViewControllerAnimated:YES]; You could paste some code in your question :)

Related

Swift Default Swipe Back - Animation

i am trying to make a swipe back animation in my App. It is working completely fine, but there are two problems I have.
The First one is, that the back swipe is working on the complete page and not only on the left side of my display.
And the second questions is, how can I have this normal back swipe animation. In my App it directly pops up.
At the moment I am only using ViewController and to switch between them I use a button with perform segue. But to get back to the pervious page I would like to use this default swipe back animation Apple is having.
Well there are multiple things happening.
the best way to handle this is to embed your first view controller inside UINavigationViewController. You can then push your second view controller and so you will get that Apple back-animation for free.
if you don't want to use NavigationController, you can at least replace that swipe recognizer with UIScreenEdgePanGestureRecognizer, so it will trigger only near the edges of screen. But it will still just pop instantly. You can't easily replicate that back animation... you'd need to use custom transition with
UIViewControllerTransitioningDelegate. And that's not easy.
My advice: learn more about UINavigationController and use it.

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.

How to implement swipe views with CollectionView/TableView Controllers?

I am creating an app using Swift, and I'm still trying to figure out what the best configuration would be.
What I'd like to have is 3 screens (the left screen would have a side out panel) that users can access via the navigation bar menu or just by swiping left/right the screen for more accessibility.
I could easily create my TableViewControllers/CollectionViewController and the menu, but I'm struggling at making the screen able to detect users gestures at the same time, and I'm not sure whether I should use 3 View Controllers and then add the Collection View/Table View via the Storyboard, or directly use the CollectionViewController/TableViewController
I added a picture here describing what I'd like to accomplish:
Also, I wonder whether I should use storyboards or not for my project.
I know that's a lot of questions !
Any ideas please ?
Thank you very much and have a good day,
J.
You need to add 2 "swipe gesture recogniser"s to your middle screen(your second screen in your attached image) , and set one for identifying left swipe and another for right swipe. Create action methods for both in your view controller and add code accessing left screen and right screen in respective methods.
note - you need to drag "swipe gesture recogniser" to top bar of your view controller scene to add it.
You can use a scrollview as a container, put three ViewController in it.

How do I create two custom segues, one for each direction?

I was able to look up a way to transition between two ViewControllers using a UIScrollView that I can use as a transition between two VCs.
I have an issue however, I have a TableView with cells that trigger a different kind of segue when tapped. (The Segue is some labels move to the new VC and other stuff appears)
I then want to be able to swipe back and forth all while the first animation is controlled by how much I swiped between. For example. if the user swipes just a small bit I want the animations to reverse back, so that if he changes his mind, he can still stay on his current VC. But if he wants to go back to the old VC, the labels animate back in place.
Basically like Snapchat but only one to go back, and the labels revert back. The other way is by tapping.
Here is a video mockup of the animation, please excuse its crudeness
You need to read up on transition controllers. What you want to do is to create a custom transition controller, specifically a UIPercentDrivenInteractiveTransition. Take a look at this tutorial on the subject:
custom UIViewController Transitions

iOS view push transitions with visible next view

I'm trying to achieve a view transition style, the one that you can see when you slide from the left side of the screen towards the middle if you're in a view that can go back. (find any app that has a back button somewhere, and just swipe from left to right starting from the edge of the screen).
The difference between this and a regular push transition is that you can see the next AND current views on the same screen and, as you slide (if you go slowly) you can really see the view and "play" with it. But right now what it does it simply quickly slide (with black on the back) and show the next view.
I'd like to be able to do that between some of my views and i have no idea how to achieve that. I'm just using a custom segue that goes left to right or right to left but that's pretty much it.
Any idea how to achieve that?
If you are using a UINavigationController and the pushViewController:animated method, then this should be the default functionality on iOS 7.0 and later. Your new UIViewController will be able to be "pulled back" by the user using a swipe right from the left of the screen.

Resources