在目标视图控制器中获取segue的发送者 [英] get sender of segue in destination view controller

查看:126
本文介绍了在目标视图控制器中获取segue的发送者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Dashboard(D)的VC,它可以打开一个名为Login(L)的VC和一个名为Register(R)的VC。登录也可以打开VC Register。

I have a VC named Dashboard (D) which can open a VC named Login (L) and a VC named Register (R). Login can open VC Register too.

我尝试尽可能多地使用storyboard,所以我用它创建了三个Segues,D到L,D到R,L到R

I try to use storyboard as often as possible, so I have created with it three Segues, D to L, D to R, L to R

所以,在D - > L - > R的情况下,在D - > R的情况下,当我关闭R时,我必须关闭L,如果它必要时告诉D他可以开始加载用户信息(简言之,启动功能)。

So, in case of D -> L -> R and in case of D -> R, when I close R, I have to close L if it necessary and inform D which he can begin to load the user infos (launch function in nutshell).

所以,我想在目标vc中获取Segue的发送者,知道我把它放在performSegueWithIdentifier的发送者entry中:

So, I would like get the sender of Segue in destination vc, knowing that I put it in sender entrie of performSegueWithIdentifier like that :

[self performSegueWithIdentifier:@"SegueToFbRegister" sender:self];


推荐答案

我这样做是让R发送通知当注册/登录完成后,让D听它然后弹出所有内容并加载你的数据。

I'd do this by having R send a notification when the registration/login is done, and having D listen to it then pop everything and load your data.

如果你坚持要求发送者,你可以在目标VC上添加此属性并将其设置在源VC的 prepareForSegue:sender:

If however you insist on getting a reference to the sender, you can add this property on your destination VC and set it in the source VC's prepareForSegue:sender:

这篇关于在目标视图控制器中获取segue的发送者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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