gpt4 book ai didi

ios - 通过 NavigationController 传递数据

转载 作者:行者123 更新时间:2023-12-01 17:24:39 25 4
gpt4 key购买 nike

我有一个 UIViewController嵌入 UINavigationController .我想介绍这个viewController并且在展示之后我还需要导航方法(Push & Pop)所以我展示UINavigationController而不是 UIViewController但为此我需要将自定义数据传递给 ViewController截至目前,我无法访问该 ViewController形成上一个 ViewController .
这是我的代码。

UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"MyNavigationIdentity"]];

[self presentViewController:navigationController animated:YES completion:nil];

P.S I cannot alloc and init new navigationController as I am designing my navigationController from Storyboard.

最佳答案

您可以访问您的 viewController来自 viewControllers UINavigationController 的属性(property).

if (navigationController.viewControllers.count > 0) {
//Cast UIViewController with your custom Controller
ViewController *vc = (ViewController*) [navigationController.viewControllers firstObject];
//Now pass data you want
vc.passData = ...
}

关于ios - 通过 NavigationController 传递数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40799092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com