iOS故事板传递数据navigationViewController
我在视图之间正确传递数据时遇到问题,但不是以标准方式传递数据。
描述我的问题的图片:
我使用两个 segue 标识符之一performSegueWithIdentifier,然后我想将数据传递给名为“Firmy”或“Oddzialy”的 ViewController。
传递数据代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"sLogowanieFirmy"]) {
FirmyVC *firmyVC = [segue destinationViewController];
firmyVC.tabFirmy = self.tabFirmy;
}
if ([[segue identifier] isEqualToString:@"sLogowanieOddzialy"]) {
OddzialyVC *oddzialyVC = [segue destinationViewController];
oddzialyVC.wybranaFirma = [self.tabFirmy objectAtIndex:0];
}
}
问题出在方法[segue destinationViewController]上,因为segue的destinationViewController是NavigationViewController。
那么传递数据和拥有独立导航控制器的正确方法是什么?
I have problem with proper passing data between view's but not in standard way.
Picture describing my problem:
I performSegueWithIdentifier with one of two segue identifiers and then in I want to pass data to ViewController called "Firmy" or "Oddzialy".
Passing data code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"sLogowanieFirmy"]) {
FirmyVC *firmyVC = [segue destinationViewController];
firmyVC.tabFirmy = self.tabFirmy;
}
if ([[segue identifier] isEqualToString:@"sLogowanieOddzialy"]) {
OddzialyVC *oddzialyVC = [segue destinationViewController];
oddzialyVC.wybranaFirma = [self.tabFirmy objectAtIndex:0];
}
}
Problem is with method [segue destinationViewController] becouse destinationViewController for segue is NavigationViewController.
So what is proper way to pass data and have independent Navigation Controllers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UINavigationController 有一个名为 topViewController 的属性,它返回位于堆栈顶部的视图控制器。
所以你的
prepareForSegue:
方法可能看起来像这样......UINavigationController
has a property calledtopViewController
which returns the view controller that is at the top of the stack.So your
prepareForSegue:
method may look something like this...这是快速的:
Here it is in swift: