how to apply condition based custom segue in storyboard

后端 未结 1 1540
无人及你
无人及你 2021-02-09 14:45

i am working on storyboards which has couple of views on first view a condition is placed i want if the condition satisfies then only navigation should happen

For this i

1条回答
  •  滥情空心
    2021-02-09 14:59

    Are you saying that you only want to perform the segue if a condition is true?

    If so, instead of creating the segue directly from a control or table cell, create a triggerless segue. A triggerless segue has the view controller as its source, and it won't ever fire automatically. Instead you can fire it programmatically any time you like, including from an IBAction.

    To create a triggerless segue, start control+dragging the segue from the containing view controller icon in the scene dock at the bottom of the scene. Drag to the destination scene like normal, and pick the segue type. Select the segue, and in the inspector, choose a segue identifier.

    At runtime, when you want to perform the segue, invoke -[UIViewController performSegueWithIdentifier:sender:]. You can pass any object you'd like for the sender, including nil. If the sender has no use to you, pass nil.

    So, in summary:

    • Create a triggerless segue from the view controller to the destination scene
    • Set an identifier for the segue in the inspector
    • At runtime, and form code, call -[UIViewController performSegueWithIdentifier:sender:] when you want to trigger the segue.

    0 讨论(0)
提交回复
热议问题