Adds capability for table_footer_view

just like table_header_view so i merged the two constructors into an each loop.
This commit is contained in:
Mark Rickert
2015-01-24 11:29:58 -05:00
parent f16b355d2e
commit 2109b2dfbb
3 changed files with 22 additions and 8 deletions

View File

@@ -144,4 +144,12 @@ class TestTableScreen < ProMotion::TableScreen
UIImageView.alloc.initWithImage(UIImage.imageNamed('test'))
end
def table_footer_view
UIView.alloc.initWithFrame(CGRectZero)
end
def on_cell_moved(args={})
self.cell_was_moved = args
end
end

View File

@@ -15,7 +15,7 @@ module ProMotion
def screen_setup
check_table_data
set_up_header_view
set_up_header_footer_views
set_up_searchable
set_up_refreshable
set_up_longpressable
@@ -30,13 +30,15 @@ module ProMotion
@promotion_table_data ||= TableData.new(table_data, table_view)
end
def set_up_header_view
if self.respond_to?(:table_header_view)
header_view = self.table_header_view
if header_view.is_a? UIView
self.tableView.tableHeaderView = header_view
else
PM.logger.warn "Table header views must be a UIView."
def set_up_header_footer_views
[:header, :footer].each do |hf_view|
if self.respond_to?("table_#{hf_view}_view".to_sym)
view = self.send("table_#{hf_view}_view")
if view.is_a? UIView
self.tableView.send(camelize("set_table_#{hf_view}_view:"), view)
else
PM.logger.warn "Table #{hf_view} view must be a UIView."
end
end
end
end

View File

@@ -175,6 +175,10 @@ describe "PM::Table module" do
@subject.tableView.tableHeaderView.class.should == UIImageView
end
it "should have a footer view" do
@subject.tableView.tableFooterView.class.should == UIView
end
describe("section with custom title_view") do
it "should use the correct class for section view" do