Skip to content

Instantly share code, notes, and snippets.

@naderhen
Last active January 1, 2016 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naderhen/8161526 to your computer and use it in GitHub Desktop.
Save naderhen/8161526 to your computer and use it in GitHub Desktop.
SideMenuController.rb
class SideMenuController < UIViewController
attr_accessor :domains
def loadView
super
end
def viewDidLoad
super
self.title = "SideMenu"
self.view.styleId = "side-menu"
self.view.backgroundColor = UIColor.whiteColor
self.domains = []
@table = UITableView.alloc.initWithFrame(CGRectMake(0, 50, self.view.frame.size.width, self.view.frame.size.height))
self.view.addSubview @table
@table.dataSource = self
@table.delegate = self
refresh
end
def refresh
load_domains
end
def load_domains
@domains = ["domain1.org", "domain2.com"]
@table.reloadData
end
def tableView(tableView, numberofSectionsinTableView: tableView)
self.domains.length
end
def tableView(tableView, numberOfRowsInSection: section)
1
end
def tableView(tableView, cellForRowAtIndexPath: indexPath)
@reuseIdentifier ||= "CELL_IDENTIFIER"
cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier)
cell = UITableViewCell.alloc.initWithStyle(
UITableViewCellStyleDefault,
reuseIdentifier: @reuseIdentifier)
cell.textLabel.text = "View Users"
cell
end
def tableView(tableView, titleForHeaderInSection:section)
self.domains[section]
end
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
ap "Selected Something"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment