对于混淆标题感到抱歉,但这是我的问题。我做了从“superVC”(collectionviewcell)到“childVC”的继续,并且运行良好。那么我想再次从那个“childVC”继续到“secondChildVC”(这是所有的数据来自superVC)。可能吗?因为我在执行那个赛季时总是得到一个零值。segue并将数据从viewcontroller传递到viewcontroller到另一个viewcontroller
它是这样的:SuperVC - > ChildVC - > secondChildVC
这里是superVC SEGUE:
var destination = [DestinationData]()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "DestinationDetailVC"{
let detailVC = segue.destination as? DestinationDetailVC
if let data = sender as? DestinationData{
detailVC?.destinationDetail = data
}
}
}
这里是第二个VC赛格瑞
var destinationDetail : DestinationData?
@IBAction func goToMapOnPressed(_ sender: Any) {
let detail = destinationDetail
self.performSegue(withIdentifier: "DestinationMapVC", sender: detail)
print(detail)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "DestinationMapVC"{
let detailVC = segue.destination as? DestinationMapVC
if let data = sender as? DestinationData{
detailVC?.destinationMapDetail = data
}
}
}
感谢
您可以使用导航控制器中的后退按钮进入前一个视图控制器。 –
错误对不起,我的不好解释...我想继续,并将数据从ChildVC传输到secondChildVC,但ChildVC中的数据来自SuperVC。它的东西像SuperVC - > ChildVC - > secondChildVC,导致所有的数据来自superVC。 @AbhishekBiswas – RoccoBerry
@RoccoBerry如果我正确理解你的问题,你可能想访问你的SuperVC和稍后在SecondChildVC中的一些数据。如果是这样,那么我建议你应该使用__singleton__。 – Adeel