Sha256: e78488de49eae3c16c27f3a931f131660917d1680d83b965bcaab85e1230c815
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
module MotionTable module SectionedTable def self.included(base) base.send :extend, MotionTable::SectionedTable end def createTableViewFromData(data) @mt_table_view_groups = data return tableView end def numberOfSectionsInTableView(tableView) return @mt_table_view_groups.length end # Number of cells def tableView(tableView, numberOfRowsInSection:section) return sectionAtIndex(section)[:cells].length end def tableView(tableView, titleForHeaderInSection:section) return sectionAtIndex(section)[:title] end def tableView(tableView, cellForRowAtIndexPath:indexPath) cellIdentifier = "Cell" cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) cell ||= UITableViewCell.alloc.initWithFrame(CGRectZero, reuseIdentifier:cellIdentifier) row = cellAtSectionAndIndex(indexPath.section, indexPath.row) cell.text = row[:title] return cell end def sectionAtIndex(index) @mt_table_view_groups.at(index) end def cellAtSectionAndIndex(section, index) return sectionAtIndex(section)[:cells].at(index) end def tableView(tableView, didSelectRowAtIndexPath:indexPath) cell = cellAtSectionAndIndex(indexPath.section, indexPath.row) tableView.deselectRowAtIndexPath(indexPath, animated: true); if self.respond_to?(cell[:action]) if cell[:arguments] self.send(cell[:action], cell[:arguments]) else self.send(cell[:action], cell[:arguments]) end else MotionTable::Console.log(self, actionNotImplemented: cell[:action]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
motion-table-0.1.4 | lib/motion-table/sectioned_table.rb |