ios - 打印变量 Unwind Segue - Xcode 8.0 Swift 3.0

标签 ios swift xcode uinavigationbar unwind-segue

我想在按下栏按钮项(在导航栏上)时打印变量。当按下此栏按钮项目时,会在设置变量时发生展开转场,然后将其打印到控制台(日志位于 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/

相关文章:

ios - Swift:在动画期间中途更改 UIImageView 图像

ios - 我们可以在部署目标低于 iOS 7 的应用程序中集成 swift 代码吗?

ios - 无法设置外键 SQLite.swift

ios - UIScrollView 内可选择的 UITableViewCells

ios - 寻找有关蓝牙 LE "Indicate"行为的信息

iphone - 将 xib 文件中的 View 旋转为横向模式

ios - 如果在 tableview iOS 中找不到数据,则无法在中心显示 View ?

iphone - 是否可以在 uikit View 层次结构之上添加具有透明 BG 的 SpriteKit 场景?

iOS 使用参数获取对 Rails API 的请求

xcode - swift 错误 : Cannot find an initializer for type 'Double' that accepts an argument list of type '(String)'