iOS Push UIViewController on slide gesture like Snapchat - ios

I have a question about iOS push navigation controllers. I want to push view controller on slide gesture. Just like as in Snapchat application: main view captures images. If you slide from left to right, snapchat messages view smoothly slides (pushes) to main window. If you slide from right to left > contacts view. How to create this kind of navigation? Thanks a lot!

I believe the way that Snapchat does it is through UIViewController containment. Essentially, the main view controller contains a scroll view (paging enabled) with 3 child view controllers (snaps, camera, and contacts). They don't use a navigation controller to present and pop view controllers as you swipe.
See the documentation on view controller containment: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

Looking through the snapchat application you probably don't want to do this all in one UINavigationController.
Here is what you need.
UIViewController - This will be your main view. In terms of the snapchat application this is where you would take picutre.
UINavigationController - For the friends list
UINavigationController - For the snapchat (the green window)
You need to setup two segues, both leading from your main controller. Once you have your segues setup I would suggest writing your own transition. Have a look at UIViewControllerContextTransitioning, UIViewControllerTransitioningDelegate, UIviewControllerAnimatedTransitioning.
I am at work, but when I get home I'll throw an example together. However, the above should get you pointed in the right direction.

Related

iOS / Swift - Swipe/Drag between ViewControllers like Telegram/iOS Settings

so I already searched a lot but maybe I missed something.
I would want to be able to drag a view to the side and drag a new view from the left.
Like in Telegram where you can slide between chats overview and a chat itself or in the iOS Settings where you can slide right and drag the detail view to the right and the overview is coming from the left.
I do know how to do segues with a slide animation, that's not what I am asking. These segues are started ones and can not be controlled by the user.
I did not use a navigation controller behind my bottom bar controller so I had the wrong transitions. When using the native Navigation Controller on all subviews of the bottom bar navigation controller you can control toolbar items and the "slide" I mentioned.

iOS Swift App SceneKit with UINavigationController

I'm currently developing an app on iOS using mostly UIKit, it's an informations and health app, not a game. It's for a company that produces chairs, so we planned to add 3D models of each chair in a small view.
I managed to import the 3D-models as chair.dae and display them using a SCNView. The complete app is build with Storyboard and Segues, combined with a UINavigationController, so the user could get back and forth on the NavigationBar.
Now the problem is, the Navigationbar on every other ViewController is working as intended.
Only on the ViewController that has the SCNView added, there is no NavigationBar at all. I used a normal ViewController, added a SCNView and connected it to my navigation with a Show Detail Segue.
Another issue is, while most Views get pulled from the right side of the screen when i switch, this one is pulled from the bottom and replaces everything
Is there a way to force it to show a navigation bar?
I tried with following, but didn't change anything
navigationController?.navigationBar.hidden = false
That sounds like correct behavior for a Show Detail. Per Apple's View Controller Programming Guide for iOS:
This segue displays the new content using the showDetailViewController:sender: method of the target view controller. This segue is relevant only for view controllers embedded inside a UISplitViewController object. With this segue, a split view controller replaces its second child view controller (the detail controller) with the new content. Most other view controllers present the new content modally.
(emphasis added).
Why not a Show instead?

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.

Drag up Child View Controller with finger and lock after point

I'm trying to implement a smooth transition between two view controllers. What I want to do is have a UIView on the bottom of VC 1. When a user swipes/drags the view upwards, VC 2 will be modally presented. What I want to have happen is as the user drags the view upwards, the view will follow the finger and VC 2 will be dragged onto the screen. As soon as the users finger has gone past a point and then been released, I want it to then lock in place.
I have successfully implemented a UIGestureRecognizer for when a user swipes up on the view. It then presents. There are only two problems with this:
1) It does not transition with the user's finger
2) There are only 4 modal transition styles (Cover Vertical, Flip Horizontal, Cross Dissolve and Partial Curl) - none of which I want to use. I want it to slide up.
I have researched and found this question How to swipe down a UIViewController from another however it hasn't helped as it presents a UIView rather than a UIViewController!
If anyone has any suggestions or example bits of code form someone who has done this before that would be great!
Thank you!
You can use UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate to do the animation which you want to do, these links can be the good starting point ios 7 custom transition
and Custom UIViewController Transitions and watch WWDC 2013 session 218 video Custom Transitions Using View Controllers

Slide viewController in navigation controller

I'd like to use a slide up / down effect to display various viewControllers inside a navigation controller. A few other apps do this like square, and every day. Basically when the app loads, I want to display a base view in the navigation controller. Then slide up another view controller over top of it. When then hit a button in the nav bar, I want to slide that down and show the base controller, all the while retaining the navigation bar, and changing up nav items.
Originally I tried to make this work by showing a modal but that requires using a new nav bar.
Has anyone done this, or knows of a good example that illustrates this UI pattern? Thank you!
You could have UIViews in a UIScrollView

Resources