Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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
Eureka Swift-位置行的设置值_Swift_Eureka Forms - Fatal编程技术网

Eureka Swift-位置行的设置值

Eureka Swift-位置行的设置值,swift,eureka-forms,Swift,Eureka Forms,我有一个表单,用户可以从包含坐标数据的多个对象中进行选择,我希望将坐标数据加载到LocationRow中 我尝试了几种不同的方法来尝试设置Location行值,但它要么崩溃(在展开可选值时意外地发现nil),要么没有用正确的数据重新加载表。i、 e My LocationRow eureka代码: $0.rowRight = LocationRow(){ $0.title = "Location" $0.tag =

我有一个表单,用户可以从包含坐标数据的多个对象中进行选择,我希望将坐标数据加载到LocationRow中

我尝试了几种不同的方法来尝试设置Location行值,但它要么崩溃(在展开可选值时意外地发现nil),要么没有用正确的数据重新加载表。i、 e

My LocationRow eureka代码:

$0.rowRight = LocationRow(){
                    $0.title = "Location"
                    $0.tag = "location"
                    if let page = selectedPage {
                        if let pageLocationLatitude = page.locationLatitude.value,
                            let pageLocationLongutude = page.locationLongitude.value {
                            print("testing for row update")
                            $0.value = CLLocation(latitude: pageLocationLatitude, longitude: pageLocationLongutude)
                        }
                    }

                }
以及当我想更新LocationRow时调用的函数

 private func setSelectedPage(pageName : String) {
        print("setting location of page: \(pageName)")
        if pageName == username {
            return
        }
        selectedPage = userPages?.filter("name == \"\(pageName)\"").first
        if let locationLongitude = selectedPage?.locationLongitude.value,
            let locationLatitude = selectedPage?.locationLatitude.value {

        print("lat and lon: \(locationLatitude) \(locationLongitude)")

        /*PURELY FOR TESTING
        let titleRow = self.form.rowBy(tag: "title") as! TextRow
        titleRow.value = "TEST WORKS OK"
        titleRow.updateCell()
        PURELY FOR TESTING */

        let locationRow = self.form.rowBy(tag: "location") as! LocationRow
        locationRow.value = CLLocation(latitude: locationLatitude, longitude: locationLongitude)
        self.form.rowBy(tag: "location")?.updateCell()
    }


   self.tableView.reloadData()
}

从您的代码中,我可以看到您正在将此位置行置于
拆分行中

// rowRight is a property of SplitRow
$0.rowRight = LocationRow(){
因此,表单并不真正了解位置行。它只知道拆分行。您应该首先使用其标记获取拆分行,然后访问
rowRight

// use the tag of your split row here!
let splitRow = self.form.rowBy(tag: "splitRow") 
                    as! SplitRow<SomeRow, LocationRow> // replace SomeRow with the type of row on the left of the split row
let locationRow = splitRow.rowRight
locationRow.value = CLLocation(latitude: locationLatitude, longitude: locationLongitude)
locationRow.updateCell()
//在此处使用拆分行的标记!
让splitRow=self.form.rowBy(标记:“splitRow”)
作为!SplitRow//将SomeRow替换为拆分行左侧的行类型
让locationRow=splitRow.rowRight
locationRow.value=CLLocation(纬度:locationLatitude,经度:LocationLength)
locationRow.updateCell()位置