Reference to the segue source view controller

跟風遠走 提交于 2019-12-05 04:04:45

There is no way to get a reference to the segue that created you. You could create a property (sourceVC in my example) in the destination controller, and assign self to this property in the prepareForSegue method (in the source view controller):

[(DestinationVCClass *)segue.destinationViewController sourceVC] = self;

You can just use [self presentingViewController] and you'll be able to access the VC that issued the segue. I usually like to couple it with isMemberOfClass: for a situation like this.

Vaish

You do the following in the unwinding segue method in the destination

self.source = (UIStoryboardSegue *)segue.sourceViewController;

Define source as a UIStoryboardSegue in the destination. The above line will give the source or the previous segue.

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