Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用展开序列发送值_Ios_Swift - Fatal编程技术网

Ios 使用展开序列发送值

Ios 使用展开序列发送值,ios,swift,Ios,Swift,大家好,我正试着用一个按钮来发送值 每当我这样做的时候 @IBAction func SENDBTN(_ sender: Any) { self.performSegue(withIdentifier: "unwindToAdd", sender: self) func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if let vc = segu

大家好,我正试着用一个按钮来发送值 每当我这样做的时候

 @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

            }
        }
    }
在addViewController中,longlat变量的值不会更改 还是零


如果有人帮助我,我将不胜感激

您似乎有错误的代码,所以让我们尝试使用下面的代码并检查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"
            }
        }

你有耐心在谷歌搜索吗

@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
            }
        }

那是你的密码吗?如果是这样的话,您需要将
prepareForSegue
函数移到
SENDBTN
函数之外。我尝试过了,没有任何结果仍然是零值。您的函数签名不正确谢谢您,但每当我在viewdidload或viewdidappear@Kamel添加打印(“已输入!!”)若要确保代码运行到该范围,请检查控制台,若并没有消息“entered!!”,请检查情节提要上的id“unwindToAdd”。对吗?我猜你的segue搞错了:)成功了!我的身份证有问题!谢谢大家帮助我D