如何在 Swift5 的函数中 运行 'performSegue'?
How To run 'performSegue' in a function on Swift5?
我是第一个 iPhone 开发者。我的问题是我想在函数中 运行 'performSegue
'。在典型的按钮功能中正常工作。但我想在一个函数中完成它。我该怎么办?
@IBAction func nextButtonFuc(_ sender: UIButton) {
...
performSegue(withIdentifier: "moveScreen", sender: self) // it's worked
}
但出现错误
@IBAction func nextButtonFuc(_ sender: UIButton) {
...
networkingCallback(objectvalue!,object,sender)
}
...
func networkingCallback( _ objectvalue: String,_ object: Any,_ send: UIButton) {
performSegue(withIdentifier: "moveScreen", sender: send) //Error
self.performSegue(withIdentifier: "moveScreen", sender: self) //Error
self.performSegue(withIdentifier: "moveScreen", sender: send) //Error
}
我该如何解决这个问题?
performSegue(withIdentifier: "moveScreen", 发件人: 发送)
Error is Implicit use of 'self' in closure; use 'self.' to make
capture semantics explicit
self.performSegue(withIdentifier: "moveScreen", sender: send) 错误
Thread 18: signal SIGABRT
提前致谢
当我看到线程相关的错误时,我就在想怎么办。而且我还以为是异步系统导致的错误。于是我通过异步执行解决了问题
DispatchQueue.main.async { self.performSegue(withIdentifier: "makeNickname", sender: self) }
我是第一个 iPhone 开发者。我的问题是我想在函数中 运行 'performSegue
'。在典型的按钮功能中正常工作。但我想在一个函数中完成它。我该怎么办?
@IBAction func nextButtonFuc(_ sender: UIButton) {
...
performSegue(withIdentifier: "moveScreen", sender: self) // it's worked
}
但出现错误
@IBAction func nextButtonFuc(_ sender: UIButton) {
...
networkingCallback(objectvalue!,object,sender)
}
...
func networkingCallback( _ objectvalue: String,_ object: Any,_ send: UIButton) {
performSegue(withIdentifier: "moveScreen", sender: send) //Error
self.performSegue(withIdentifier: "moveScreen", sender: self) //Error
self.performSegue(withIdentifier: "moveScreen", sender: send) //Error
}
我该如何解决这个问题?
performSegue(withIdentifier: "moveScreen", 发件人: 发送)
Error is Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
self.performSegue(withIdentifier: "moveScreen", sender: send) 错误
Thread 18: signal SIGABRT
提前致谢
当我看到线程相关的错误时,我就在想怎么办。而且我还以为是异步系统导致的错误。于是我通过异步执行解决了问题
DispatchQueue.main.async { self.performSegue(withIdentifier: "makeNickname", sender: self) }