ios - 如何将值传递给嵌入在 NavigationController 中的 viewController

标签 ios objective-c uinavigationcontroller storyboard

有类似的问题,但它们要么很快,要么没有解决我的问题。
我有一个 View Controller ,当按下单元格选择按钮时,它会显示导航 View Controller :

patientBillNavigationViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PatientBillVC"];
//soem value assignment
[self presentViewController:viewController animated:YES completion:nil];

您可以说计费打开了一个全新的 View ,独立于主要应用程序流程来处理计费流程。
这个导航 View Controller 自动加载的 View 是账单 View ,现在如果我想将一个值从这个 View Controller 传递到嵌入在导航 View 中的另一个 View Controller ,我不能这样做。如何传递一个值?

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
            PatientBillViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"PBVC"];

            vc.superBillToAddEdit = sb;
//then display the view embedded in navigation view

但这行不通。

最佳答案

我知道的一种方法是子类化 UINavigationViewController 并在其 viewDidLoad 中,您可以:

 YourEmbeddedVc *svc =self.viewControllers[0]; //get the controller reference
 svc.name= @"Hello";

我假设您的导航堆栈中只有一个 Controller ,否则您需要找到所需 VC 的正确匹配。

关于ios - 如何将值传递给嵌入在 NavigationController 中的 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40027800/

相关文章:

ios - 内部选项卡栏 View Controller 导航栏更改无法从 Storyboard 中工作

ios - 空 tableView 上没有结果标签

ios - 如何在 Xcode 8 中创建没有 LaunchScreen 的空应用程序

objective-c - 为什么我的 UINavigationController 右键加载后就消失了

ios - 如何在iOS 10 上播放UIPickerView 的滴答声?

ios - Swift - 编码 URL

objective-c - Objective C 中的天数列表

iphone - “保持” UIButton 行为 - `Touch Cancelled` 控制状态阻止进一步的控制状态

objective-c - 在 View Controller 子类上添加导航 Controller

iphone - UI 导航后退按钮与 "multi paged"父 View 配合使用的问题