daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  2.       let row = indexPath.row
  3.      
  4.       let cellFromCache = postItemCellsCache[row]
  5.       let post = posts[row]
  6.      
  7.       // bla bla bla
  8.      
  9.       let cell = tableView.dequeueReusableCell(withIdentifier: "PostsCellWithVideo", for: indexPath) as! PostsCellWithVideo
  10.          
  11.          // force update of height
  12.          cell.frame.size.width = view.frame.width
  13.          let width = view.frame.size.width
  14.          let height = width * CGFloat(post.mediaAspectRatio)
  15.          cell.spotPostMediaHeight.constant = height
  16.          cell.layoutIfNeeded() // layoutIfNeeded inserted redundantly
  17.          
  18.          // added all code here, but in real, they are all divided into funcs
  19.          cell.player.view.frame = cell.spotPostMedia.bounds
  20.          cell.player.view.frame.size.height = cell.spotPostMedia.frame.height
  21.          cell.player.view.layoutIfNeeded()
  22.          cell.layoutIfNeeded()
  23.          cell.player.fillMode = PlayerFillMode.resizeAspectFill.avFoundationType
  24.      
  25.          self.addChildViewController(cell.player)
  26.          cell.spotPostMedia.addSubview(cell.player.view)
  27.          cell.player.didMove(toParentViewController: self)
  28.          
  29.          // bla bla bla
RAW Paste Data
Top