XLForm dynamically change section title

170 Views Asked by At

I just started using XLForm and faced some problems. I have a section which title I have to change depending on field above it. So when I select an option, I need the same title for section. In code I do:

if formRow.tag == "subCategory" {

        switch newValue.description {
        case lightVehicle:
            vehicleSection.hidden = false
            mileageRow!.hidden = false
            break
        case heavyVehicle:
            mileageRow!.hidden = true
            mileageRow!.value = nil
            vehicleTypeRow!.hidden = true
            break
        case bikes:
            mileageRow?.hidden = true
            vehicleTypeRow!.hidden = false
            break

        default:break
        }
        // Here I set the title
        vehicleSection.title = newValue.description
    }

So I know that the value is changed, but for displaying it I need smth like reloadFormRow(). Unfortunately there is no such method for sections

I found hacky way to do that is tableView.reloadData(), but in documentation they not recommend do any manipulations directly with tableView itself.

0

There are 0 best solutions below