Ios 如何通过推入NavigationStack将值传递给另一个ViewController?
这是我的密码Ios 如何通过推入NavigationStack将值传递给另一个ViewController?,ios,swift,Ios,Swift,这是我的密码 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if indexPath.row == 0{ self.navigationController?.pushViewController(self.storyboard?.instantiateViewControllerWithIdentifier("History") as! H
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0{
self.navigationController?.pushViewController(self.storyboard?.instantiateViewControllerWithIdentifier("History") as! History, animated: true)
TV.deselectRowAtIndexPath(indexPath, animated: false)
}
}
我推到另一个ViewController(名为History)并希望将此ViewController中的值传递给History ViewController
我知道我们可以使用segue和segue的destinationViewController和sourceViewController传递值
但在这种情况下没有segue
所以,我不知道如何将var的值分配给历史的var
有人能帮我吗
let history = self.storyboard?.instantiateViewControllerWithIdentifier("History") as! History
//在这里你可以访问历史变量
history.yourVar=Assign Value
self.navigationController?.pushViewController(history, animated: true)
TV.deselectRowAtIndexPath(indexPath, animated: false)
//在这里你可以访问历史变量
history.yourVar=Assign Value
self.navigationController?.pushViewController(history, animated: true)
TV.deselectRowAtIndexPath(indexPath, animated: false)
哦,不。我问了一个多么愚蠢的问题。好的,谢谢你的回答。读了你的答案后,我想这很容易。哦,不,我问了一个多么愚蠢的问题。好的,谢谢你的回答。读了你的答案后,我想这是一件很容易的事。