nicklockwood / FXForms

[DEPRECATED]
Other
2.93k stars 339 forks source link

FXFormFieldTypeOption: tapping option doesn't unwind back to main form view #406

Open eliotstock opened 9 years ago

eliotstock commented 9 years ago

I'm getting this problem in v 1.2.13 when selecting an option for a field with an array of strings as the options. I have a dynamic form, building up a set of fields in a fields() method on the form. The problem field is defined like this:

        fields.append([
            FXFormFieldHeader: "Device \(device.identifier)",
            FXFormFieldTitle: "This bike is",
            FXFormFieldKey: "\(settingsFormFieldKeyDeviceState)\(device.identifier)",
            FXFormFieldType: FXFormFieldTypeOption,
            FXFormFieldOptions: settingsFormFieldStateOptions,
            FXFormFieldAction: "didChangeState:"])

where the options are:

let settingsFormFieldStateOptions = ["Safe", "Suspected Stolen", "Stolen"]

Because I'm using keys generated at runtime, I've overridden valueForUndefinedKey() on the form.

If I click the field I get a new view pushed onto the nav controller as expected. If I then click a value the didChangeState action is called properly, but the UI doesn't unwind back to the main form view. It also doesn't move the checkmark from the old value to the new one I just clicked. How do I make this work?

Thanks.

eliotstock commented 9 years ago

Having run the examples now, I see that I shouldn't expect the unwinding to happen automatically. The user will just have to click Back above after changing the value. So the only issue is that the checkmark doesn't move.

frakman1 commented 8 years ago

What I do, is put some code to pop back to the parent view on the navigation controller stack. Like this:

(in your didChangeState method)

[self.navigationController popViewControllerAnimated:YES];

Not sure about Swift but might look like this:

if let navController = self.navigationController {
    navController.popViewControllerAnimated(true)
}