Class: Tgios::UIPickerViewListBinding
Instance Method Summary
collapse
Methods inherited from BindingBase
#dealloc, #hook, #prepareForRelease, #unhook
Constructor Details
Returns a new instance of UIPickerViewListBinding.
3
4
5
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 3
def initialize
@events={}
end
|
Instance Method Details
#bind(picker_view, options = {}) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 11
def bind(picker_view, options={})
@options = options
@picker_view=WeakRef.new(picker_view)
@list=WeakRef.new(options[:list])
@display_field=options[:display_field]
@picker_view.dataSource=self
@picker_view.delegate=self
end
|
#get_display_text(row) ⇒ Object
43
44
45
46
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 43
def get_display_text(row)
record = @list[row]
record.is_a?(Hash) ? record[@display_field] : record.send(@display_field)
end
|
#numberOfComponentsInPickerView(pickerView) ⇒ Object
21
22
23
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 21
def numberOfComponentsInPickerView(pickerView)
1
end
|
#on(event_name, &block) ⇒ Object
7
8
9
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 7
def on(event_name, &block)
@events[event_name]=block.weak!
end
|
#onPrepareForRelease ⇒ Object
63
64
65
66
67
68
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 63
def onPrepareForRelease
@events=nil
@picker_view.dataSource=nil
@picker_view.delegate=nil
@list=nil
end
|
#pickerView(pickerView, didSelectRow: row, inComponent: component) ⇒ Object
25
26
27
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 25
def pickerView(picker_view, numberOfRowsInComponent:section)
@list.length
end
|
#reload(list = nil) ⇒ Object
57
58
59
60
61
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 57
def reload(list=nil)
@list = WeakRef.new(list) if list
NSLog "#{@list.length}====="
@picker_view.reloadAllComponents
end
|
#select_record(record) ⇒ Object
52
53
54
55
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 52
def select_record(record)
idx = (@list.find_index(record) || 0)
@picker_view.selectRow(idx, inComponent:0, animated: false)
end
|
#selected_record ⇒ Object
48
49
50
|
# File 'lib/tgios/ui_picker_view_list_binding.rb', line 48
def selected_record
@list[@picker_view.selectedRowInComponent(0)]
end
|