有类似的问题,但它们要么很快,要么没有解决我的问题。
我有一个 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/