通过NavigationController传递数据

时间:2016-11-25 06:39:58

标签: ios objective-c uiviewcontroller uinavigationcontroller

我有一个UIViewController嵌入UINavigationController。我想提出这个viewController并在呈现之后我还需要导航方法(Push& Pop),所以我提交的是UINavigationController而不是UIViewController,但为此,我需要将自定义数据传递给我ViewController之前无法访问之前ViewController的{​​{1}}表单。 这是我的代码。

ViewController
  

P.S当我从Storyboard设计导航控制器时,我无法UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"MyNavigationIdentity"]]; [self presentViewController:navigationController animated:YES completion:nil]; allocinit

2 个答案:

答案 0 :(得分:4)

您只需使用ViewController属性

访问UINavigationController childViewControllers内嵌的NSArray *viewControllers = [navigationController childViewControllers]; if (viewControllers.count > 0) { UIViewController *myViewController = (UIViewController *)[viewControllers firstObject]; } 即可
environments {
development {
    grails {
        mail {
            host = "smtp.gmail.com"
            port = 465
            username = "xxxxx@xxxxxx"
            password = jasypt
            props = ["mail.smtp.auth":"true",
                "mail.smtp.socketFactory.port":"465",
                "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
                "mail.smtp.socketFactory.fallback":"false"]

        }
    }
}
production {
    grails.logging.jul.usebridge = false
}

答案 1 :(得分:4)

您可以从viewController的{​​{1}}媒体资源中访问viewControllers

UINavigationController