从另一个ViewController在嵌入式ViewController中传递数据

时间:2018-09-21 09:46:53

标签: ios swift firebase eureka-forms

地图是这样的:

  

MasterVC(1)----> DetailsVC(2)---> EmbedVC(3)

map

我要复制一些数据并在初始化表单之前将其填入Embedded VC MasterVC

                 let vc = DetailsVC(2)
              ref.observe(.value) { (snapshot) in
                var playerValues = [String:Any]()
                if snapshot.exists() {
                    let values = snapshot.value as! [String:Any]
                    playerValues = values
                    print(ref) 
                }

                vc.values = playerValues
              }
   self.navigationController?.pushViewController(vc, animated: true)

EmbedVC

var values = [String:Any]()

viewDidLoad{
    valueTableSetup()
    }        
    func valueTableSetup() {



            form +++ Section("Position")
                <<< SegmentedRow<String>() {

                    $0.selectorTitle = "Position"
                    $0.options = ["GK","DEF","MID","ATT"]
                    $0.value =  playerValues["Position"] as? String
                    $0.tag = "Position"
                    }.onChange({ (row) in
                        let value = row.value
                        ref.updateChildValues(["Position" : value])
                    })
            form +++ Section("Preferred Side")
                <<< SegmentedRow<String>() {
                    $0.selectorTitle = "Preferred Side"
                    $0.options = ["Left","Middle","Right"]
                    $0.value = "Right"    // initially selected
                    $0.tag = "Preferred Side"
            }
    }

我正在以编程方式进行操作,因此没有情节提要。 我还尝试将其从第一个VC(1)传递给EmbedVC(3),以及从(2)传递给(3),但没有结果。 每次我尝试从PlayerValues [String:Any]获取值都为nil 我正在使用Eureka作为表单生成器。 我尝试将统计信息下载到 valueTableSetup()中,还尝试在ViewDidLoad和ViewDidAppear中运行代码。

0 个答案:

没有答案