使用 XLPagerTabStrip 在 children 之间传递数据
passing data between children using XLPagerTabStrip
我正在使用 https://github.com/xmartlabs/XLPagerTabStrip,我有 3 个 children ...我想将值从 child 传递到 child ..
我能够像这样将值从 parent 传递到第一个 child:
let parentVC = self.parent as! ParentViewController
mobile = parentVC.mobile
但现在我想将它从 child 1 传递到 child 2 .. 尝试了上面的方法,但我知道 mobile 是 nil
parent视图中的移动设备声明如下:
var mobile = ""
如何在 children 之间传递数据?
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]
}
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]
}
我正在使用 https://github.com/xmartlabs/XLPagerTabStrip,我有 3 个 children ...我想将值从 child 传递到 child ..
我能够像这样将值从 parent 传递到第一个 child:
let parentVC = self.parent as! ParentViewController
mobile = parentVC.mobile
但现在我想将它从 child 1 传递到 child 2 .. 尝试了上面的方法,但我知道 mobile 是 nil
parent视图中的移动设备声明如下:
var mobile = ""
如何在 children 之间传递数据?
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]
}
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]
}