Skip to content

Instantly share code, notes, and snippets.

@ivangodfather
Created August 24, 2015 12:28
Show Gist options
  • Select an option

  • Save ivangodfather/05cf8ee5a1e357fb82ec to your computer and use it in GitHub Desktop.

Select an option

Save ivangodfather/05cf8ee5a1e357fb82ec to your computer and use it in GitHub Desktop.
class MenuVC: UIViewController {
private var menuItems = AppearanceService.template().menuItems()
private let cellIdentifier = "menu"
var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
let nib = AppearanceService.template().menuItemNib()
self.tableView.registerNib(nib, forCellReuseIdentifier: cellIdentifier)
tableView.estimatedRowHeight = 80
tableView.rowHeight = UITableViewAutomaticDimension
}
}
extension MenuVC: UITableViewDataSource {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var menuItem = menuItems[indexPath.row]
if SomeConition {
let cell = UITableViewCell(frame: CGRectZero)
return cell
}
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as! MenuItemCell
cell.menuItem = menuItem
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment