bcylin / QuickTableViewController

A simple way to create a UITableView for settings in Swift.

Home Page:https://bcylin.github.io/QuickTableViewController

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to not auto toggle UISwitch on touch?

MhmdSalah opened this issue · comments

I am trying to link the UISwitch in SwitchRow to a bool value, but every time i click on the switch it toggles without checking the value in the init function.
Is there a way to change it in the action by accessing the Row parameter in the completion? i cannot find it!
Thanks!

commented

but every time I click on the switch it toggles

That's the purpose of UISwitch, isn't it?

I'm not quite sure if I understand the behaviour you described. Do you mind sharing some of your code as an example?

but every time I click on the switch it toggles

That's the purpose of UISwitch, isn't it?

I'm not quite sure if I understand the behaviour you described. Do you mind sharing some of your code as an example?

Sorry my explanation is lacking.
Sometimes after the user tries to activate the switch, the activation will fail and i want the switch to go back to its old state. So, i need a reference to the UISwitch in the action completion handler.
Is there a reference that i am missing? the only reference i get is a Row variable that does not give me the option to control the UISwitch. Do i need to cast it in some way?

commented

I see. The SwitchRow wasn't really designed for this scenario. One possible workaround is that you can mutate the SwitchRow in the action block by casting the Row variable as SwitchRowCompatible.

But I'd suggest a method to recreate the tableContents, and call this method when the activation fails. It should reload the table view with the old state. Hope it helps.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.