Sha256: 44e5477cce2655ecbb20a8f09975e8d71411550841d0970c77fdee0bef5104f9
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
motion_require 'base' motion_require 'items_mapper' module Formotion module RowType class OptionsRow < Base include BW::KVO include RowType::ItemsMapper 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems