swift – iOS 16: AVPlayerViewController’s contentOverlayView has bad layout


After the release of iOS 16 we started getting feedback that the video controls were no longer appearing. Sure enough, testing with a device with iOS 16 was giving us different results than 15.

When hitting the screen with the UI Debugger I found:

UI Debgger

The contentOverlayView was no longer the same size as the containing AVPlayerViewController view. Inspecting it shows:


So, the contentOverlayView has ambiguous height/Y constraints, but this is a view controlled by AVPlayerViewController. Again, iOS 15 and earlier didn’t have this issue (and the code has remained the same for a few years now).

Here is the existing code that:

  1. Clears the contentOverlayView of any existing subviews
  2. Initializes and sets up the custom video controls for the app
  3. Adds the controls to the contentOverlayView setting the anchors.
  4. It then adds the player’s view to a passed in superview and sets the anchors for that.
    override func addTo(superview: UIView) {
        if let contentOverlayView = moviePlayer.contentOverlayView {
            movieControls = ADMovieControlsView(delegate: self, subtitles: subtitleUrl)
            if let movieControls = movieControls {
                movieControls.allowFastForward = fastforwardingAllowed
                movieControls.allowsDismissal = allowsDismissal
                movieControls.translatesAutoresizingMaskIntoConstraints = false

                movieControls.topAnchor.constraint(equalTo: contentOverlayView.topAnchor).isActive = true
                movieControls.bottomAnchor.constraint(equalTo: contentOverlayView.bottomAnchor).isActive = true
                movieControls.leadingAnchor.constraint(equalTo: contentOverlayView.leadingAnchor).isActive = true
                movieControls.trailingAnchor.constraint(equalTo: contentOverlayView.trailingAnchor).isActive = true
        moviePlayer.view.translatesAutoresizingMaskIntoConstraints = false
        moviePlayer.view.topAnchor.constraint(equalTo: superview.topAnchor).isActive = true
        moviePlayer.view.bottomAnchor.constraint(equalTo: superview.bottomAnchor).isActive = true
        moviePlayer.view.leadingAnchor.constraint(equalTo: superview.leadingAnchor).isActive = true
        moviePlayer.view.trailingAnchor.constraint(equalTo: superview.trailingAnchor).isActive = true

Does anyone know if this is a known iOS 16 bug or if something changed that requires code updating? Thank you