34

I am trying to find out what the difference is between a custom UIStoryboardSegue and a custom UIViewcontroller transition (introduced in ios7).

What are the differences and different use cases for both? As far as I can tell they are both used for custom moves to new controllers.

Possibly the UIViewcontroller transitions are used more for a controller that is only shown and will some point be dismissed, whilst the segue is a complete move and not necessarily a back?

Custom Segues
UIViewControllerTransitioningDelegate Protocol Reference

5
  • Segue defines the action (dismiss A and show B) between two view controller, and whereas view controller transition describes how view controller appears or dismisses.
    – Danyun Liu
    Commented Jan 14, 2014 at 17:54
  • Are you trying to say that a segue has a specific direction whilst a View Controller transition does not it has a presenting and presented view controller and either animates one in or out?
    – StuartM
    Commented Jan 14, 2014 at 17:58
  • What I mean is segue encapsulates the action such as [vc1 push:xxx] or [vc1 presentModal:xxx], it is a convenient way to present v2 from v1 with default transition(push, modal) defined, you don't need to write such code, but just call [self performSegueWithIdentifier:xxx]. And In my opinion, the transition delegate allows you to custom the animation effect.
    – Danyun Liu
    Commented Jan 14, 2014 at 18:09
  • @Danyun - Thanks so what does a custom segue do... the same? Allows you to customise the animation effect between the action? In my current app I use a segue in the storyboard and call self performSegueWithIdentifier as suggested but then use a custom transition for the animation.
    – StuartM
    Commented Jan 14, 2014 at 20:29
  • A small point for anyone googling to here - if you're just getting in to this here's a long long explanation of how to set it up .. stackoverflow.com/a/23403979/294884 may help!
    – Fattie
    Commented Jun 17, 2014 at 9:51

2 Answers 2

3

Custom Segues are not just for defining the presentation styles but they can also be used for defining custom hierarchy of view controllers along with presentation styles--something different from Navigation or Tab bar view controllers.

The issue with using custom segue only for presentation is that developer is responsible for managing the view controller hierarchy also, which is not actually the intent.

With custom transitions API, presentation is separated from how view controllers are managed.

1
  • 2
    This makes sense. Is there any way to trigger view controller transitions from custom segues or any other way of keeping the separation when using custom segues? Commented Jan 6, 2015 at 14:17
0

If you use storyboard segues and you want a custom transition, you would use a custom UIStoryboardSegue. But if you're using regular UIViewController methods for presenting new view controllers, you would use a custom UIViewController transition. In both cases, your previous view controller(s) still exist and you can go back if you desire. It just depends on which method you want to use to bring up a new view controller.

3
  • 2
    I am not sure this is correct as you can use UIViewController Transitioning with segues without issue. I have setup some view controller transitions already and use segues in conjunction with them, even the custom transitions. However, I do not know the difference between these and use cases.
    – StuartM
    Commented Jan 14, 2014 at 17:57
  • You could, yes. But I think you can only use a custom UIStoryboardSegue when actually using segues.
    – Gavin
    Commented Jan 14, 2014 at 17:58
  • @StuartM There is at least one case where you can't use UIViewControllerTransitioningDelegate with storyboard segues. When you have a custom container view controller with multiple children, and you want a custom segue to transition from one child to another child and properly perform -addChildViewController: on the container controller, a standard presentation transition doesn't work, because it won't handle the parenting. AFAICT, you have to do this parenting yourself, and a custom segue is a logical place for that – but then UIViewControllerTransitioningDelegate is not used.
    – erikprice
    Commented Mar 6, 2016 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.