Added delete_cell method. Should address #110

This commit is contained in:
Mark Rickert
2013-06-01 13:11:07 -04:00
parent a937e804eb
commit 5b4937d8f2
2 changed files with 21 additions and 2 deletions

View File

@@ -80,6 +80,16 @@ module ProMotion
trigger_action(data_cell[:accessory_action], data_cell[:arguments]) if data_cell[:accessory_action]
end
def delete_row(index_paths, animation = nil)
animation ||= UITableViewRowAnimationAutomatic
index_paths = [index_paths] unless index_paths.is_a? Array
index_paths.each do |index_path|
@promotion_table_data.delete_cell(index_path: index_path)
end
table_view.deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation)
end
########## Cocoa touch methods #################
def numberOfSectionsInTableView(table_view)
return Array(@promotion_table_data.data).length
@@ -118,8 +128,6 @@ module ProMotion
trigger_action(cell[:action], cell[:arguments]) if cell[:action]
end
# Old aliases, deprecated, will be removed
alias :createTableViewFromData :create_table_view_from_data
alias :updateTableViewData :update_table_view_data

View File

@@ -31,6 +31,17 @@ module ProMotion
nil
end
def delete_cell(params={})
if params[:index_path]
params[:section] = params[:index_path].section
params[:index] = params[:index_path].row
end
table_section = self.section(params[:section])
return table_section[:cells].delete_at(params[:index].to_i)
nil
end
def search(search_string)
self.filtered_data = []
self.filtered = true