Search code examples
seguewatchkitapple-watch

WatchKit how do I perform a specific segue with an identifier


I have a button that is already hooked up in the InterfaceBuilder to bring up a modal interface controller. In some cases I'd like to trigger this transition programmatically but I can't find a way to perform that same segue in Watchkit. I know you can do this in iphones/iOS but so far I can't find it in the Watchkit.


Solution

  • It can be done programatically. You need to set the Identifier in the storyBoard for the interface.

    If you want it to present modally

    presentControllerWithName("Identifier", context: nil)
    

    If you want to push

    pushControllerWithName("Identifier", context: nil)
    

    You can set context if you like. You can retrieve it in the controller you push/present

    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context)
    }