0

我正在使用https://github.com/xmartlabs/XLPagerTabStrip,我有 3 个孩子......我想将价值从孩子传递给孩子......

能够像这样将值从父母传递给第一个孩子:

    let parentVC = self.parent as! ParentViewController
    mobile = parentVC.mobile

但是现在我想将它从孩子 1 传递给孩子 2 .. 尝试了上面的方法,但我发现手机是 nil

在此处输入图像描述

父视图中的移动设备声明如下:

    var mobile = ""

如何在孩子之间传递数据?

       override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "cominfo")
    let child2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "comedu")
    let child3 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "comcv")        
    return [child1,child2,child3]
}

在此处输入图像描述

4

1 回答 1

2
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "cominfo") as! yourChildClassname
    child1.mobile = self.mobile
    let child2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "comedu")as! yourChildClassname
    child2.mobile = self.mobile
    let child3 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "comcv")  as! yourChildClassname
    child3.mobile = self.mobile       
return [child1,child2,child3]
 }
于 2018-07-26T07:27:52.127 回答