Guest User

Untitled

a guest
Nov 13th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.96 KB | None | 0 0
  1. class CustomCell: UICollectionViewCell, UITableViewDataSource, UITableViewDelegate {
  2.  
  3.     var tableView = UITableView()
  4.     let cellIdentifier: String = "tableViewCell"
  5.  
  6.     override func layoutSubviews() {
  7.         super.layoutSubviews()
  8.  
  9.         tableView.delegate = self
  10.         tableView.dataSource = self
  11.  
  12.         tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
  13. }
  14.  
  15. func numberOfSections(in tableView: UITableView) -> Int {
  16.     return 1 // How many sections you want
  17. }
  18.  
  19. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  20.     return 1 // How many rows per section you want
  21. }
  22.  
  23. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  24.  
  25.     let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle, reuseIdentifier: cellIdentifier)
  26.  
  27.     cell.textLabel?.text = "1 CUP"
  28.     cell.detailTextLabel?.text = "Whole"
  29.  
  30.     return cell
  31. }
Advertisement
Add Comment
Please, Sign In to add comment