Make Segue programmatically in Swift

后端 未结 2 1491
太阳男子
太阳男子 2020-12-18 20:25

I have two VCs: VC1 and VC2. In VC1, I have a finish button which I programmatically made and a result array I want to pass to VC2.

I know

2条回答
  •  佛祖请我去吃肉
    2020-12-18 20:52

    You can still create the segue in Interface Builder by dragging from VC1 to VC2 - just drag from/to the little yellow circle at the top of the VC. Give this segue a unique name in IB, and in your finish function you can call performSegueWithIdentifier:, pass in the name of your segue, and that's it. In the prepareForSegue method you can find out which segue is being performed by accessing segue.identifier, and if it's the segue in question you can get a pointer to segue.destinationViewController and pass your data on that way.

提交回复
热议问题