5
我正在使用swift应用程序,并使用presentViewController
创建了其他视图的链接,但我无法弄清楚如何传递变量。如何将变量传递给新视图?在Swift中使用PresentViewController传递变量
@IBAction func WorkoutPressed(sender: AnyObject) {
let storyBoard = UIStoryboard(name: "Main", bundle:nil)
let workoutView = storyBoard.instantiateViewControllerWithIdentifier("workoutView") as WorkoutViewController
self.presentViewController(workoutView, animated: false, completion: nil)
//self.navigationController?.pushViewController(workoutView, animated: true)
}
感谢
'workoutView.someVariable =“是的,就这么简单”#: – 2014-12-06 00:37:21
因此,在self.presentViewController之前,我有一行可以添加参数?我在哪里设置哪些变量是参数? – Marcus 2014-12-06 00:44:59
你为什么要调用它们的参数?即使您从对象之外设置它们,它们也是变量。如果你的viewController有一个变量,你可以设置它。或者你是否将WorkoutViewController的变量设置为私有? ---我建议你编辑你的问题来显示一个你不能设置的变量的例子。有几种可能性阻止你从外部设置变量。所以也许你遇到过其中之一。但是你必须展示一些真实的代码,否则我们无法提供帮助。 – 2014-12-06 00:49:03