mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-05-07 23:07:01 +08:00
57 lines
1.4 KiB
Ruby
57 lines
1.4 KiB
Ruby
class <%= @name_camel_case %>Controller < UITableViewController
|
|
|
|
<%= @name.upcase %>_CELL_ID = "<%= @name_camel_case %>Cell"
|
|
|
|
def viewDidLoad
|
|
super
|
|
|
|
load_data
|
|
|
|
rmq.stylesheet = <%= @name_camel_case %>ControllerStylesheet
|
|
|
|
view.tap do |table|
|
|
table.delegate = self
|
|
table.dataSource = self
|
|
rmq(table).apply_style :table
|
|
end
|
|
end
|
|
|
|
def load_data
|
|
@data = 0.upto(rand(100)).map do |i| # Test data
|
|
{
|
|
name: %w(Lorem ipsum dolor sit amet consectetur adipisicing elit sed).sample,
|
|
num: rand(100),
|
|
}
|
|
end
|
|
end
|
|
|
|
def tableView(table_view, numberOfRowsInSection: section)
|
|
@data.length
|
|
end
|
|
|
|
def tableView(table_view, heightForRowAtIndexPath: index_path)
|
|
rmq.stylesheet.<%= @name %>_cell_height
|
|
end
|
|
|
|
def tableView(table_view, cellForRowAtIndexPath: index_path)
|
|
data_row = @data[index_path.row]
|
|
|
|
cell = table_view.dequeueReusableCellWithIdentifier(<%= @name.upcase %>_CELL_ID) || begin
|
|
rmq.create(<%= @name_camel_case %>Cell, :<%= @name %>_cell, reuse_identifier: <%= @name.upcase %>_CELL_ID).get
|
|
end
|
|
|
|
cell.update(data_row)
|
|
cell
|
|
end
|
|
|
|
# Remove if you are only supporting portrait
|
|
def supportedInterfaceOrientations
|
|
UIInterfaceOrientationMaskAll
|
|
end
|
|
|
|
# Remove if you are only supporting portrait
|
|
def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
|
|
rmq.all.reapply_styles
|
|
end
|
|
end
|