0
我正在嘗試在我的視圖控制器之間傳輸一個值。當我只是我的按鈕連接到其他視圖控制器,這樣的:(Swift)在視圖控制器之間傳輸數據
我能夠使它發揮作用。我壓倒prepareforSegue
。
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var DestinationViewController : ViewTwo = segue.destinationViewController as! ViewTwo
DestinationViewController.scoretext = score.text!
}
這一切工作正常,但當我以編程方式打開其他控制器時,值不會傳輸。這是我使用的代碼...
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : ViewTwo = storyboard.instantiateViewControllerWithIdentifier("viewtwo") as! ViewTwo
self.presentViewController(vc, animated: true, completion: nil)
謝謝,這樣做! – Ash