0

When I add a video (AVPlayer) to a UITableView, and scroll down the cells, the video stays up and disappears unless i scroll back up. Is there a way to make the background video Fixed?

What i want to achieve is a background video, with cells filled with texts on top of the video, & no matter how much i scroll to new cells, the video should stay in the full view fixed.

Just imagine a twitter feed with a background video to the whole view, not a specific cell.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • It sounds like you want the video as a background view behind the whole table, not one cell. Have you tried that? – Connor Neville Sep 26 '16 at 14:33
  • @ConnorNeville Yes, and the problem i'm getting is that it is not fixed, as soon as i scroll down it goes away, unless i scroll back up. AVPlayers uses layers to add the video rather than the subview directly, could that be the problem? – Whitebeard Sep 27 '16 at 09:43

1 Answers1

1

If you want to obtain a StarWar-esque effect why don't you:

  1. Set the UITableView (and if needed the UITableViewCell) a transparent background

  2. Add a container UIView behind the UITableView (as a child of the parent of the tableview, ...aka a sibling) with same constraints or frame/autoconst-mask as the UItableView and you put your AVPlayer (or whatever videoview) inside it? Or add directly the video-view without container view.

Community
  • 1
  • 1
jalone
  • 1,953
  • 4
  • 27
  • 46
  • I will try the first approach and get back. However adding the video-view directly is what i did, but since AVPlayer uses the sublayer of a view instead of adding it directly to the subview, it becomes not fixed and you can scroll away from the video – Whitebeard Sep 27 '16 at 09:42
  • This did not work. I believe since I'm scrolling outside the screen's frame's height container view of the video also get left behind. It seems there is no solution to this unless i have the video expand with the uitableview which is an ideal solution. Thank you – Whitebeard Oct 09 '16 at 14:31