Drag Segue To Self in Storyboard

我只是一个虾纸丫 提交于 2020-01-03 10:56:13

问题


I want to drag a segue from my viewcontroller, to itself. So I can push "infinite" instances of that particular view controller.

I know how to do this in code (I.e instansiate the view controller programmatically). However, I want to use segues as far as possible.

I've found a few "hacks" for making segue to self in storyboard, but I don't like hacks, so my question is;

Is there a clean way to make a segue back to self in the Storyboard? I dont want to drag it from a button or such, I just want a generic segue that i can use with:

[self performSegueWithIdentifier:@"segueIdentifier"]

Thanks.


回答1:


You can do this in the storyboard itself. Drag a Storyboard Reference from the Object Library, and then control drag from your view controller to the storyboard reference to create a segue, and select the type of transition. Then with the storyboard reference selected, make sure it's attributes in the inspector are set to the same storyboard file, and the same view controller referenced by it's storyboard ID.




回答2:


You can drag the segue from the trigger to the same view controller. You'll need to drag it to the the yellow box in the top left, on top of the view controller in Xcode 6.

If you try to drag it onto the VC itself Xcode will think that you're trying to add a layout constraint.




回答3:


You can embed your TableViewController in a Navigation Controller and segue to the Navigation controller.



来源:https://stackoverflow.com/questions/21937496/drag-segue-to-self-in-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!