Use a hash for accessories instead of individual properties.

This commit is contained in:
Mark Rickert
2013-06-07 13:09:14 -04:00
parent 1c2ebf773b
commit 1e967713df
2 changed files with 15 additions and 7 deletions

View File

@@ -73,10 +73,10 @@ module ProMotion
index_path = table_cell.superview.indexPathForCell(table_cell)
data_cell = cell_at_section_and_index(index_path.section, index_path.row)
data_cell[:arguments] = {} unless data_cell[:arguments]
data_cell[:arguments][:value] = switch.isOn if data_cell[:arguments].is_a? Hash
data_cell[:accessory][:arguments] = {} unless data_cell[:accessory][:arguments]
data_cell[:accessory][:arguments][:value] = switch.isOn if data_cell[:accessory][:arguments].is_a? Hash
trigger_action(data_cell[:accessory_action], data_cell[:arguments]) if data_cell[:accessory_action]
trigger_action(data_cell[:accessory][:action], data_cell[:accessory][:arguments]) if data_cell[:accessory][:action]
end
def delete_row(index_paths, animation = nil)

View File

@@ -43,15 +43,23 @@ module ProMotion
end
def set_accessory_view
# Legacy Support < 0.7.4
data_cell[:accessory] ||= data_cell[:accessory_view]
data_cell[:accessory] = {
view: data_cell[:accessory],
value: data_cell[:accessory_value],
action: data_cell[:accessory_action],
arguments: data_cell[:accessory_arguments]
} unless data_cell[:accessory].is_a? Hash
# End Legacy Support
if data_cell[:accessory] == :switch
if data_cell[:accessory][:view] == :switch
switch_view = UISwitch.alloc.initWithFrame(CGRectZero)
switch_view.addTarget(self.closest_parent(UITableView), action: "accessory_toggled_switch:", forControlEvents:UIControlEventValueChanged)
switch_view.on = true if data_cell[:accessory_checked]
switch_view.on = true if data_cell[:accessory][:value]
self.accessoryView = switch_view
elsif data_cell[:accessory]
self.accessoryView = data_cell[:accessory]
elsif data_cell[:accessory][:view]
self.accessoryView = data_cell[:accessory][:view]
self.accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth
end