引用 segue 源视图控制器 [英] Reference to the segue source view controller

查看:45
本文介绍了引用 segue 源视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 viewDidLoad 中,我想要一些基于前一个控制器的自定义代码.

Within my viewDidLoad I would like some custom code based upon the previous controller.

如何在目标控制器的 viewDidLoad 中访问 segue 源控制器或前一个 segue 标识符来处理此问题?

How can I access the segue source controller or the previous segue identifier in the destination controller's viewDidLoad to handle this?

推荐答案

没有办法获得对创建您的 segue 的引用.您可以在目标控制器中创建一个属性(在我的示例中为 sourceVC),并在 prepareForSegue 方法(在源视图控制器中)中将 self 分配给该属性:

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;

这篇关于引用 segue 源视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆