我想在按下栏按钮项(在导航栏上)时打印变量。当按下此栏按钮项目时,会在设置变量时发生展开转场,然后将其打印到控制台(日志位于 Xcode 底部)。这是我的代码:
@IBAction func doneNavItem(_ sender: AnyObject) {
textField.text = var variableUnwind
print(variableUnwind)
}
我知道在从 How to do something before unwind segue action? 打印变量之前会触发展开转场。但这里的解决方案似乎不起作用,或者我可能读错了。
谢谢
最佳答案
请将您的变量设置代码移动到prepare for segue方法中。
@IBOutlet weak var testTextField: UITextField!
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
var variableUnwind = ("StackOverFlow")
print(variableUnwind)
let textContents = testTextField.text
print(textContents)
}
关于ios - 打印变量 Unwind Segue - Xcode 8.0 Swift 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40061782/