Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let row = indexPath.row
- let cellFromCache = postItemCellsCache[row]
- let post = posts[row]
- // bla bla bla
- let cell = tableView.dequeueReusableCell(withIdentifier: "PostsCellWithVideo", for: indexPath) as! PostsCellWithVideo
- // force update of height
- cell.frame.size.width = view.frame.width
- let width = view.frame.size.width
- let height = width * CGFloat(post.mediaAspectRatio)
- cell.spotPostMediaHeight.constant = height
- cell.layoutIfNeeded() // layoutIfNeeded inserted redundantly
- // added all code here, but in real, they are all divided into funcs
- cell.player.view.frame = cell.spotPostMedia.bounds
- cell.player.view.frame.size.height = cell.spotPostMedia.frame.height
- cell.player.view.layoutIfNeeded()
- cell.layoutIfNeeded()
- cell.player.fillMode = PlayerFillMode.resizeAspectFill.avFoundationType
- self.addChildViewController(cell.player)
- cell.spotPostMedia.addSubview(cell.player.view)
- cell.player.didMove(toParentViewController: self)
- // bla bla bla
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement