How to make swipe between Controllers with animation? - ios

I have my structure like
Controller 1 <-> Controller 2 <-> Controller 3 <-> ...<->Controller N
I need to be able to access to controller 1 or 3 directly from another controllers. I need swipe animation between controllers 1-n , and navigation bar with < and > buttons.
What is the best solution for this swiping controllers? I need be able to do some animation there. Do i need use paged UIScrollView? or UIPageViewController? With animation - CALayer transition?
Please, help me to choose.

Hello #Alexander and anyone else who needs a solution to this problem,
I think the easiest way to deal with this situation would be to use the UIGestures which will give great animations and will simply be justified using the storyboard. To use it from one view controller to the other, just do the following:
If your side view is open, this will show up on the bottom right side of the storyboard:
Then, you will have to drag the swipe gesture recognizer to the initial view controller and then let go when the whole view is highlighted in blue:
After that, you will have to control-drag the gesture icon on the top of the initial view controller to the controller you want to connect to. Then it will show a drop down list after you let go of the highlighted controller. Pick any segue:
You can do this with all the view controllers by creating more gestures and segues. You can also do it from the same view controller back or even skip controllers with different types of gesture recognizers.
I hoped it helped :)

Related

Swipe to the same Viewcontroller

I am trying to implement a left-right swipe gesture to navigate between an array of objects, that i can change the properties and take actions. The navigation is more of a previous-next approach. I have a table view that segues to this Viewcontroller, and i would like the user to check the next object without getting back to the TableViewcontroller. What is the best approach to implement this?
I know PageController isn't ideal in my situation as i'm not navigating between different VCs.
A page view controller is the best way. Make the views view controllers instead. It does all the work for you.
Failing that you could use a collection view with a custom flow layout.
Failing that, you could roll your own custom view controller that implemented this feature.
EDIT:
Based on your screenshot, where you say "swipe back and forth to move between rows of a table view" you need a collection view. Table views scroll up and down between rows. That's what they are made to do, and trying to implement a swipe interface to instead scroll side-to-side is crazy. Simply use a collection view configured for horizontal scrolling between cells.

For swift iOS app dev, how do I segue to a view that takes up part of the screen only?

GroupMe is a good example. I want to implement something similar to this..
when you press the top left icon it'll bring you to the view on the left hand side, and when you click the right hand side of that view (the chats) it will bring you back
As the documentation says:
Use segues to define the flow of your app’s interface. A segue defines
a transition between two view controllers in your app’s storyboard
file. The starting point of a segue is the button, table row, or
gesture recognizer that initiates the segue. The end point of a segue
is the view controller you want to display. A segue always presents a
new view controller, but you can also use an unwind segue to dismiss a
view controller.
As said by Apple© segues are for changing View Controllers only and cannot be used to move single views. I suggest using animations to achieve the effect you are searching, however segues are definitely not what you are looking for. Maybe this question on stackoverflow.com may help you.
And please be sure to check for information by yourself first, I got this information in less than 5 minutes by searching on Google.com.
Regards -Jorge

Push view controller in navigation controller with interactive transition

I have a view at the bottom of my view controller. How can I set up an interactive transition such that as I drag the view up vertically (perhaps using UIPanGestureRecognizer), another view controller is pushed up?
Similar to the default navigation controller behaviour with swiping left and right to push/pop, except this would be vertical.
You can use UIDynamicAnimator class for animation.
You will have to use AttachmentBehavior for such kind of attachment animation. It's subclass of UIDynamicAnimator. Please check this question. It might help you.

Segue to "self" - Transition back to initial controller

I would like to have three separate tableViews, show the middle view automatically (root view), and access the other two via a button or segmented control. That logic can come later. When I access the first I want it to slide in from the left, when I access the third I want it to slide in from the right to give it the appearance of the middle view controller always being there and only moving left and right via transitions.
Using storyboard segues is giving way to many complications - because my tableViewController is the initial root view, there is no way to segue to self from self when the button or segmented control is accessed. I feel like this must be a semi-standard implementation. Is there a best practice to implement this UI? Should I build my own custom container class and swap controllers and associated view in and out?
You should create 2 segues from you root to left and right table view. When you would like to go back, to root controller, use unwind segues.
What are Unwind segues for and how do you use them?

Custom segue from left to right for form sheets (iPad)

I have some view controllers in a form sheet and right now they all push segue. But I want to make an animation that makes them come from right to left during segue throughout the page. so when I go to the next view controller my segue should start bringing the view controller from the right and the parent view controller starts to move to the left and goes off the screen/fades and the child view controller comes from right and settles at the center of the iPad like how form sheets do. I was wondering if anyone had implemented something like that before? if not, can I get some suggestions in how to do this so that I can get a head start? I have just have a little experience with custom segues, where I could use QuartzCore to animate the view controllers and since they all belong to the same navigation controller I am not sure how can I achieve this fly from right to center and to left animation.
You can create your own full-sized view controller and emulate form sheet's behavior inside it by yourself (with gesture recognizers etc)

Resources