简体   繁体   English

如何从其他故事板场景中的主要故事板场景访问变量?

[英]How to access variables from main storyboard scene in other storyboard scenes?

I am developing an app that has 3 storyboard scenes. 我正在开发一个具有3个故事板场景的应用程序。 In the first storyboard scene, I have some variables that I want to access in other two scenes. 在第一个情节提要面板场景中,我想在其他两个场景中访问一些变量。 How can I do it? 我该怎么做? I navigate to other two scenes using Storyboard segue and calling the following on button click 我使用情节提要segue导航到其他两个场景,并在单击按钮时调用以下内容

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

Use this method 使用这个方法

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"nameofsegue"]) {
        YourDestinationVC *dvc = [segue destinationViewController];
        YourSourceVC *svc = (YourSourceVC*)sender;
        //set your ivr here
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM