Class: Loco::UI::TableView

Inherits:
UITableView
  • Object
show all
Includes:
Observable, Resizable
Defined in:
lib/motion-loco/table_view.rb

Instance Attribute Summary

Attributes included from Resizable

#bottom, #height, #left, #parentView, #parent_view, #right, #top, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Observable

#init, #initWithStyle, #initialize, #method_missing, #register_observer, #remove_all_observers, #remove_observer, #set_properties, #update_attributes

Methods included from Resizable

included, #refresh_layout, #viewSetup, #view_setup, #willMoveToSuperview

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Loco::Observable

Class Method Details

.get_item_view_classObject



105
106
107
# File 'lib/motion-loco/table_view.rb', line 105

def get_item_view_class
  @item_view_class ||= TableViewCell
end

.item_view_class(view_class) ⇒ Object Also known as: itemViewClass



100
101
102
# File 'lib/motion-loco/table_view.rb', line 100

def item_view_class(view_class)
  @item_view_class = view_class
end

Instance Method Details

#cell_idObject



58
59
60
# File 'lib/motion-loco/table_view.rb', line 58

def cell_id
  @cell_id ||= "CELL_#{self.object_id}"
end

#content=(value) ⇒ Object



53
54
55
56
# File 'lib/motion-loco/table_view.rb', line 53

def content=(value)
  super
  self.reloadData
end

#initWithFrame(frame) ⇒ Object



62
63
64
65
# File 'lib/motion-loco/table_view.rb', line 62

def initWithFrame(frame)
  super(frame)
  self.dataSource = self.delegate = self
end

#item_view_classObject



67
68
69
# File 'lib/motion-loco/table_view.rb', line 67

def item_view_class
  self.class.get_item_view_class
end

#tableView(tableView, numberOfRowsInSection: section) ⇒ Integer

UITableViewDelegate implementation for returning the number of rows in a section.

Returns:

  • (Integer)


73
74
75
76
77
78
79
80
# File 'lib/motion-loco/table_view.rb', line 73

def tableView(tableView, cellForRowAtIndexPath:indexPath)
  cell = tableView.dequeueReusableCellWithIdentifier(cell_id) 
  unless cell
    cell = self.item_view_class.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:cell_id)
  end
  cell.content = self.content[indexPath.row]
  cell
end