Programmatic Popover launch

I'm using Storyboard for my iPad app but need to launch a Popover controller (created in Storyboard) from code rather than from a button segue. How do I do this?

Best Answer

  • AlexCorradoAlexCorrado US Xamurai
    Accepted Answer

    You can create a segue that can be triggered from code. It's basically the same idea as a button segue, except you ctrl+drag from the view controller instead of the button. You'll also need to set the identifier for this segue. Then you trigger it by calling PerformSegue.

Answers

  • AlexCorradoAlexCorrado USXamarin Team Xamurai
    Accepted Answer

    You can create a segue that can be triggered from code. It's basically the same idea as a button segue, except you ctrl+drag from the view controller instead of the button. You'll also need to set the identifier for this segue. Then you trigger it by calling PerformSegue.

  • SidKauffmanSidKauffman USMember

    Thanks! I had tried that by just guessing, but I grabbed the bottom box and it just moved the controller around. Dragging from the status bar works, as does dragging from the Document Outline. I got a "UIStoryboardPopoverSegue must be presented from a bar button item or a view." This was fixed in the popover Attributes inspector by ctrl-dragging from Anchor to where I wanted the popover to point, and referencing that in my call. Six months and I'm still a beginner. Thanks again for your help.

Sign In or Register to comment.