mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-06-01 02:10:22 +08:00
Added delete_cell method. Should address #110
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user