Search code examples
iosuiviewcontrollerpushviewcontrollersnapchat

iOS Push UIViewController on slide gesture like Snapchat


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!


Solution

  • 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