Class: Formotion::RowType::SwitchRow
- Includes:
- BW::KVO
- Defined in:
- lib/formotion/row_type/switch_row.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#_on_select, #after_build, #after_delete, #break_with_semaphore, #button?, #cellEditingStyle, #cell_style, #delete_row, #done_editing, field_buffer, #indentWhileEditing?, #initialize, #input_accessory_view, #on_delete, #on_select, #update_cell, #with_semaphore
Constructor Details
This class inherits a constructor from Formotion::RowType::Base
Instance Method Details
#build_cell(cell) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/formotion/row_type/switch_row.rb', line 8 def build_cell(cell) cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleNone switchView = UISwitch.alloc.initWithFrame(CGRectZero) switchView.accessibilityLabel = (row.title || "") + " Switch" cell.accessoryView = cell.editingAccessoryView = switchView switchView.setOn(row.value || false, animated:false) switchView.when(UIControlEventValueChanged) do break_with_semaphore do row.value = switchView.isOn end end switchView.userInteractionEnabled = row.editable? observe(self.row, "value") do |old_value, new_value| break_with_semaphore do switchView.setOn(row.value || false, animated: false) end end nil end |