Creating a segue programmatically

前端 未结 13 1159
名媛妹妹
名媛妹妹 2020-11-22 12:41

I have a common UIViewController that all my UIViewsControllers extend to reuse some common operations.

I want to set up a segue on this \"

13条回答
  •  臣服心动
    2020-11-22 13:26

    Storyboard Segues are not to be created outside of the storyboard. You will need to wire it up, despite the drawbacks.

    UIStoryboardSegue Reference clearly states:

    You do not create segue objects directly. Instead, the storyboard runtime creates them when it must perform a segue between two view controllers. You can still initiate a segue programmatically using the performSegueWithIdentifier:sender: method of UIViewController if you want. You might do so to initiate a segue from a source that was added programmatically and therefore not available in Interface Builder.

    You can still programmatically tell the storyboard to present a view controller using a segue using presentModalViewController: or pushViewController:animated: calls, but you'll need a storyboard instance.

    You can call UIStoryboards class method to get a named storyboard with bundle nil for the main bundle.

    storyboardWithName:bundle:

提交回复
热议问题