mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-04-23 20:00:52 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user