2017-10-08 42 views
0

我在同一個ViewControllerA中有ViewControllerA和一個子視圖。我想知道如何將ViewContorllerA的出口標籤值傳遞給它的子視圖。如何將ViewContorller的出口值傳遞給它的子視圖Swift

+0

如果我這樣做是正確,你可以通過創建一個[*代表*](https://stackoverflow.com/questions/40501780/examples-of-delegates-in-swift-3/40503024做#40503024)到您的子視圖並通過其方法傳遞所需的值。提到的答案中包含「例如」部分,這可能是做這種事情的一個很好的起點。 –

+0

感謝您的示例。我無法得到它。我在VC_A中有一個插座標籤,它包含一個子視圖。事情是,suBView想要知道VC_A標籤值的值。 (這裏的子視圖也在VC_A中)。 –

回答

0

請嘗試使用此方法。我認爲這會對你有用。在這裏傳遞你的插座價值。

  let destVC = self.storyboard?.instantiateViewController(withIdentifier: "CategoryDescriptionViewController_id") as? CategoryDescriptionViewController 

      destVC?.aTitleText = "" 

      destVC?.aDescText = "" 

      destVC?.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height) 
      self.addChildViewController(destVC ?? UIViewController()) 
      self.view.addSubview((destVC?.view)!) 
      destVC?.didMove(toParentViewController: self) 
+0

感謝您的示例。我無法得到它。我在VC_A中有一個插座標籤,它包含一個子視圖。事情是,suBView想要知道VC_A標籤值的值。 (這裏的子視圖也在VC_A中)。 –

相關問題