Created
August 24, 2015 12:28
-
-
Save ivangodfather/05cf8ee5a1e357fb82ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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