iOS storyboard passing data navigationViewController

后端 未结 2 1140
情歌与酒
情歌与酒 2020-12-02 15:24

I have problem with proper passing data between view\'s but not in standard way.

Picture describing my problem:

相关标签:
2条回答
  • 2020-12-02 16:23

    Here it is in swift:

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) 
    {    
        if (segue.identifier == "sLogowanieFirmy") {
            let nav = segue.destinationViewController as! UINavigationController 
            let firmyVC = nav.topViewController as! FirmyVC
            firmyVC.tabFirmy = self.tabFirmy            
        }
    
        // etc...
    }
    
    0 讨论(0)
  • 2020-12-02 16:27

    UINavigationController has a property called topViewController which returns the view controller that is at the top of the stack.

    So your prepareForSegue: method may look something like this...

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([[segue identifier] isEqualToString:@"sLogowanieFirmy"]) {
            UINavigationController *nav = [segue destinationViewController];
            FirmyVC *firmyVC = (FirmyVC *)nav.topViewController;
            firmyVC.tabFirmy = self.tabFirmy;
        }
    
        // etc...
    }
    
    0 讨论(0)
提交回复
热议问题