你好我们正在尝试使用unwind segue使用按钮发送值 无论何时我这样做
@IBAction func SENDBTN(_ sender: Any) {
self.performSegue(withIdentifier: "unwindToAdd", sender: self)
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let vc = segue.destination as? AddViewController {
vc.longlat = self.longlat
}
}
}
longlat变量的值在addViewController中不会改变 仍然没有。
如果有人帮助我会感激的
答案 0 :(得分:1)
您是否耐心搜索Google?
@IBAction func sendData(_ sender: Any) {
self.performSegue(withIdentifier: "showData", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?){
if (segue.identifier == "showData"){
let vc = segue.destination as! ProfilePage
}
}
答案 1 :(得分:0)
看起来你的代码错了,所以让我们试试下面的代码并检查addViewController中longlat变量的值。
@IBAction func SENDBTN(_ sender: Any) {
self.performSegue(withIdentifier: "unwindToAdd", sender: self)
}
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let vc = segue.destination as? AddViewController {
//vc.longlat = self.longlat
print("entered !!!")
vc.longlat = "hard code some value"
}
}