Class: Formotion::RowType::OptionsRow
- Includes:
- BW::KVO, ItemsMapper
- Defined in:
- lib/formotion/row_type/options_row.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from ItemsMapper
#item_names, #item_names_hash, #items, #name_for_value, #name_index_of_value, #value_for_name, #value_for_name_index
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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/formotion/row_type/options_row.rb', line 10 def build_cell(cell) cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleNone segmentedControl = UISegmentedControl.alloc.initWithItems(item_names || []) segmentedControl.selectedSegmentIndex = name_index_of_value(row.value) if row.value segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar segmentedControl.userInteractionEnabled = row.editable? cell.accessoryView = cell.editingAccessoryView = segmentedControl segmentedControl.when(UIControlEventValueChanged) do break_with_semaphore do row.value = value_for_name_index(segmentedControl.selectedSegmentIndex) end end observe(self.row, "value") do |old_value, new_value| break_with_semaphore do if row.value segmentedControl.selectedSegmentIndex = name_index_of_value(row.value) else segmentedControl.selectedSegmentIndex = UISegmentedControlNoSegment end end end nil end |