Can't make custom segue in Xcode 10/iOS 12










0















I'm having the hardest time implementing a presentation of a drawer sliding partway up on the screen on iPhone.



EDIT: I've discovered that iOS is not respecting the .custom modalTransitionStyle I've set in the Segue. If I set that explicitly in prepareForSegue:, then it calls my delegate to get the UIPresentationController.



I have a custom Segue that is also a UIViewControllerTransitioningDelegate. In the perform() method, I set the destination transitioningDelegate to self:



self.destination.transitioningDelegate = self


and I either call super.perform() (if it’s a Present Modal or Present as Popover Segue), or self.source.present(self.destination, animated: true) (if it’s a Custom Segue, because calling super.perform() throws an exception).



The perform() and animationController(…) methods get called, but never presentationController(forPresented…).



Initially I tried making the Segue in the Storyboard "Present Modally" with my custom Segue class specified, but that kept removing the presenting view controller. I tried "Present as Popover," and I swear it worked once, in that it didn't remove the presenting view controller, but then on subsequent attempts it still did.



So I made it "Custom," and perform() is still being called with a _UIFullscreenPresentationController pre-set on the destination view controller, and my presentationController(forPresented…) method is never called.



Other solutions dealing with this issue always hinge on some mis-written signature for the method. This is mine, verbatim:



public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?


I've spent the last four days trying to figure out “proper” custom transitions, and it doesn't help that things don’t seem to behave as advertised. What am I missing?










share|improve this question
























  • Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

    – gebirgsbärbel
    Nov 13 '18 at 12:31











  • The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

    – Rick
    Nov 13 '18 at 12:32











  • After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

    – gebirgsbärbel
    Nov 13 '18 at 12:36











  • I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

    – Rick
    Nov 13 '18 at 12:38











  • Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

    – gebirgsbärbel
    Nov 13 '18 at 12:40















0















I'm having the hardest time implementing a presentation of a drawer sliding partway up on the screen on iPhone.



EDIT: I've discovered that iOS is not respecting the .custom modalTransitionStyle I've set in the Segue. If I set that explicitly in prepareForSegue:, then it calls my delegate to get the UIPresentationController.



I have a custom Segue that is also a UIViewControllerTransitioningDelegate. In the perform() method, I set the destination transitioningDelegate to self:



self.destination.transitioningDelegate = self


and I either call super.perform() (if it’s a Present Modal or Present as Popover Segue), or self.source.present(self.destination, animated: true) (if it’s a Custom Segue, because calling super.perform() throws an exception).



The perform() and animationController(…) methods get called, but never presentationController(forPresented…).



Initially I tried making the Segue in the Storyboard "Present Modally" with my custom Segue class specified, but that kept removing the presenting view controller. I tried "Present as Popover," and I swear it worked once, in that it didn't remove the presenting view controller, but then on subsequent attempts it still did.



So I made it "Custom," and perform() is still being called with a _UIFullscreenPresentationController pre-set on the destination view controller, and my presentationController(forPresented…) method is never called.



Other solutions dealing with this issue always hinge on some mis-written signature for the method. This is mine, verbatim:



public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?


I've spent the last four days trying to figure out “proper” custom transitions, and it doesn't help that things don’t seem to behave as advertised. What am I missing?










share|improve this question
























  • Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

    – gebirgsbärbel
    Nov 13 '18 at 12:31











  • The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

    – Rick
    Nov 13 '18 at 12:32











  • After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

    – gebirgsbärbel
    Nov 13 '18 at 12:36











  • I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

    – Rick
    Nov 13 '18 at 12:38











  • Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

    – gebirgsbärbel
    Nov 13 '18 at 12:40













0












0








0








I'm having the hardest time implementing a presentation of a drawer sliding partway up on the screen on iPhone.



EDIT: I've discovered that iOS is not respecting the .custom modalTransitionStyle I've set in the Segue. If I set that explicitly in prepareForSegue:, then it calls my delegate to get the UIPresentationController.



I have a custom Segue that is also a UIViewControllerTransitioningDelegate. In the perform() method, I set the destination transitioningDelegate to self:



self.destination.transitioningDelegate = self


and I either call super.perform() (if it’s a Present Modal or Present as Popover Segue), or self.source.present(self.destination, animated: true) (if it’s a Custom Segue, because calling super.perform() throws an exception).



The perform() and animationController(…) methods get called, but never presentationController(forPresented…).



Initially I tried making the Segue in the Storyboard "Present Modally" with my custom Segue class specified, but that kept removing the presenting view controller. I tried "Present as Popover," and I swear it worked once, in that it didn't remove the presenting view controller, but then on subsequent attempts it still did.



So I made it "Custom," and perform() is still being called with a _UIFullscreenPresentationController pre-set on the destination view controller, and my presentationController(forPresented…) method is never called.



Other solutions dealing with this issue always hinge on some mis-written signature for the method. This is mine, verbatim:



public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?


I've spent the last four days trying to figure out “proper” custom transitions, and it doesn't help that things don’t seem to behave as advertised. What am I missing?










share|improve this question
















I'm having the hardest time implementing a presentation of a drawer sliding partway up on the screen on iPhone.



EDIT: I've discovered that iOS is not respecting the .custom modalTransitionStyle I've set in the Segue. If I set that explicitly in prepareForSegue:, then it calls my delegate to get the UIPresentationController.



I have a custom Segue that is also a UIViewControllerTransitioningDelegate. In the perform() method, I set the destination transitioningDelegate to self:



self.destination.transitioningDelegate = self


and I either call super.perform() (if it’s a Present Modal or Present as Popover Segue), or self.source.present(self.destination, animated: true) (if it’s a Custom Segue, because calling super.perform() throws an exception).



The perform() and animationController(…) methods get called, but never presentationController(forPresented…).



Initially I tried making the Segue in the Storyboard "Present Modally" with my custom Segue class specified, but that kept removing the presenting view controller. I tried "Present as Popover," and I swear it worked once, in that it didn't remove the presenting view controller, but then on subsequent attempts it still did.



So I made it "Custom," and perform() is still being called with a _UIFullscreenPresentationController pre-set on the destination view controller, and my presentationController(forPresented…) method is never called.



Other solutions dealing with this issue always hinge on some mis-written signature for the method. This is mine, verbatim:



public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?


I've spent the last four days trying to figure out “proper” custom transitions, and it doesn't help that things don’t seem to behave as advertised. What am I missing?







ios custom-transition






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 0:25







Rick

















asked Nov 13 '18 at 10:10









RickRick

1,1961318




1,1961318












  • Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

    – gebirgsbärbel
    Nov 13 '18 at 12:31











  • The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

    – Rick
    Nov 13 '18 at 12:32











  • After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

    – gebirgsbärbel
    Nov 13 '18 at 12:36











  • I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

    – Rick
    Nov 13 '18 at 12:38











  • Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

    – gebirgsbärbel
    Nov 13 '18 at 12:40

















  • Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

    – gebirgsbärbel
    Nov 13 '18 at 12:31











  • The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

    – Rick
    Nov 13 '18 at 12:32











  • After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

    – gebirgsbärbel
    Nov 13 '18 at 12:36











  • I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

    – Rick
    Nov 13 '18 at 12:38











  • Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

    – gebirgsbärbel
    Nov 13 '18 at 12:40
















Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

– gebirgsbärbel
Nov 13 '18 at 12:31





Hi Rick, I have a hard time figuring out, how your custom transition is going wrong. Can you maybe post the code for your custom transition or attach the link to a minimal test example? Also I assume you are using two standard ViewControllers, no NavigationController involved. Am I correct?

– gebirgsbärbel
Nov 13 '18 at 12:31













The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

– Rick
Nov 13 '18 at 12:32





The presenting view controller is inside a UINavigationController (it’s the only one). I can’t post the code at the moment but will later today.

– Rick
Nov 13 '18 at 12:32













After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

– gebirgsbärbel
Nov 13 '18 at 12:36





After reading your question again, I assume, that you want to have a drawer that overlays your current view, similar to the one in Apple Maps. As far as I know, you should not do this using to view controllers, as on iOS only one ViewController can be shown at the same time, but use a UIView instead.

– gebirgsbärbel
Nov 13 '18 at 12:36













I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

– Rick
Nov 13 '18 at 12:38





I don’t think that’s true. You can have split view controllers on iPhone, and I’ve seen an example in a WWDC video where they make a popover on iPhone.

– Rick
Nov 13 '18 at 12:38













Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

– gebirgsbärbel
Nov 13 '18 at 12:40





Hm, I would have to recheck, but if using a UIView instead of a separate ViewController also would be fine for you, here is an excellent tutorial, that shows how to implement drawers on iOS: raywenderlich.com/…

– gebirgsbärbel
Nov 13 '18 at 12:40












1 Answer
1






active

oldest

votes


















0














Instead of using a custom presentation segue, you could use a Container View for your drawer. This way, you can use a UIViewController for your Drawer content, while avoiding the issue with the custom segue.



You achieve this in two steps:
First pull a Container View into your main view controller and layout it properly. The storyboard would look like this: (You can see you have two view controllers. One for the main view and one for the drawer)



enter image description here



Second, you create an action that animates the drawer in and out as needed. One simple example could look like this:



@IBAction func toggleDrawer(_ sender: Any) 
let newHeight: CGFloat
if drawerHeightConstraint.constant > 0
newHeight = 0
else
newHeight = 200


UIView.animate(withDuration: 1)
self.drawerHeightConstraint.constant = newHeight
self.view.layoutIfNeeded()




Here, I simply change the height constraint of the drawer, to slide it in and out. Of course you could do something more fancy :)



You can find a demo project here.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278581%2fcant-make-custom-segue-in-xcode-10-ios-12%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Instead of using a custom presentation segue, you could use a Container View for your drawer. This way, you can use a UIViewController for your Drawer content, while avoiding the issue with the custom segue.



    You achieve this in two steps:
    First pull a Container View into your main view controller and layout it properly. The storyboard would look like this: (You can see you have two view controllers. One for the main view and one for the drawer)



    enter image description here



    Second, you create an action that animates the drawer in and out as needed. One simple example could look like this:



    @IBAction func toggleDrawer(_ sender: Any) 
    let newHeight: CGFloat
    if drawerHeightConstraint.constant > 0
    newHeight = 0
    else
    newHeight = 200


    UIView.animate(withDuration: 1)
    self.drawerHeightConstraint.constant = newHeight
    self.view.layoutIfNeeded()




    Here, I simply change the height constraint of the drawer, to slide it in and out. Of course you could do something more fancy :)



    You can find a demo project here.






    share|improve this answer



























      0














      Instead of using a custom presentation segue, you could use a Container View for your drawer. This way, you can use a UIViewController for your Drawer content, while avoiding the issue with the custom segue.



      You achieve this in two steps:
      First pull a Container View into your main view controller and layout it properly. The storyboard would look like this: (You can see you have two view controllers. One for the main view and one for the drawer)



      enter image description here



      Second, you create an action that animates the drawer in and out as needed. One simple example could look like this:



      @IBAction func toggleDrawer(_ sender: Any) 
      let newHeight: CGFloat
      if drawerHeightConstraint.constant > 0
      newHeight = 0
      else
      newHeight = 200


      UIView.animate(withDuration: 1)
      self.drawerHeightConstraint.constant = newHeight
      self.view.layoutIfNeeded()




      Here, I simply change the height constraint of the drawer, to slide it in and out. Of course you could do something more fancy :)



      You can find a demo project here.






      share|improve this answer

























        0












        0








        0







        Instead of using a custom presentation segue, you could use a Container View for your drawer. This way, you can use a UIViewController for your Drawer content, while avoiding the issue with the custom segue.



        You achieve this in two steps:
        First pull a Container View into your main view controller and layout it properly. The storyboard would look like this: (You can see you have two view controllers. One for the main view and one for the drawer)



        enter image description here



        Second, you create an action that animates the drawer in and out as needed. One simple example could look like this:



        @IBAction func toggleDrawer(_ sender: Any) 
        let newHeight: CGFloat
        if drawerHeightConstraint.constant > 0
        newHeight = 0
        else
        newHeight = 200


        UIView.animate(withDuration: 1)
        self.drawerHeightConstraint.constant = newHeight
        self.view.layoutIfNeeded()




        Here, I simply change the height constraint of the drawer, to slide it in and out. Of course you could do something more fancy :)



        You can find a demo project here.






        share|improve this answer













        Instead of using a custom presentation segue, you could use a Container View for your drawer. This way, you can use a UIViewController for your Drawer content, while avoiding the issue with the custom segue.



        You achieve this in two steps:
        First pull a Container View into your main view controller and layout it properly. The storyboard would look like this: (You can see you have two view controllers. One for the main view and one for the drawer)



        enter image description here



        Second, you create an action that animates the drawer in and out as needed. One simple example could look like this:



        @IBAction func toggleDrawer(_ sender: Any) 
        let newHeight: CGFloat
        if drawerHeightConstraint.constant > 0
        newHeight = 0
        else
        newHeight = 200


        UIView.animate(withDuration: 1)
        self.drawerHeightConstraint.constant = newHeight
        self.view.layoutIfNeeded()




        Here, I simply change the height constraint of the drawer, to slide it in and out. Of course you could do something more fancy :)



        You can find a demo project here.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 11:09









        gebirgsbärbelgebirgsbärbel

        1,38211631




        1,38211631





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278581%2fcant-make-custom-segue-in-xcode-10-ios-12%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

            Museum of Modern and Contemporary Art of Trento and Rovereto