我使用 dimissViewControllerAnimated 将视图从 Spring Insert Variables 返回到 Spring Element 。同时,我的输入数据应该通过 Spring Element 类中的unwindSecondView函数从 Spring Insert Variables 传递回 Sprint Element 。 / p>
但显然数据没有通过,我的数组:力和刚度仍然不包含值。有人可以就此提出建议吗?
代码来自Spring Insert Variables类
class springInsertVariables : UIViewController {
var forceVar = [Float] ()
var stiffVar = [Float] ()
@IBOutlet weak var forceEntered: UITextField!
@IBOutlet weak var stiffnessEntered: UITextField!
@IBAction func submit(sender: AnyObject) {
forceVar.append((forceEntered.text as NSString).floatValue)
stiffVar.append((stiffnessEntered.text as NSString).floatValue)
println(forceVar) //This doesn't print on my output
println(stiffVar) //This doesn't print on my output
dismissViewControllerAnimated(true, completion: nil)
}
}
Spring Element Class的代码
@IBAction func unwindSecondView(segue: UIStoryboardSegue) {
if let svcspringinsertvariables = segue.sourceViewController as? springInsertVariables {
self.force = svcspringinsertvariables.forceVar
self.stiffness = svcspringinsertvariables.stiffVar
println(force)
println(stiffness)
}
}
答案 0 :(得分:1)
dismissViewControllerAnimated
实际上并没有使用unwind segue。展开segue与任何其他segue一样,必须使用performSegueWithIdentifier
执行。