youtube / youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Other
1.64k stars 680 forks source link

YTPlayerView in self-sizing UITableView in Swift #428

Closed kml404 closed 3 years ago

kml404 commented 3 years ago

In my Swift application, I have some UITableView's nested 3 levels deeps. The cells are self-sizing and the innermost cells (greatgrandchildren of the main UITableView, if you will) contain a vertical UIStackView with a label and a YTPlayerView object, both of which get populated at runtime. My team worked long and hard at perfecting this self-sizing nested table, and we're happy to say everything works fine except for the videos.

How can we ensure the YTPlayerView's update the same way the rest of the table does?

kml404 commented 3 years ago

I figured out a solution, but I wish it were built-in. The secret for me is adding a 16:9 (standard YT video) aspect ratio constraint to each YTPlayer object.