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:
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:
contentOverlayView
of any existing subviewscontentOverlayView
setting the anchors. override func addTo(superview: UIView) {
if let contentOverlayView = moviePlayer.contentOverlayView {
contentOverlayView.subviews.forEach({$0.removeFromSuperview()})
movieControls = ADMovieControlsView(delegate: self, subtitles: subtitleUrl)
if let movieControls = movieControls {
movieControls.allowFastForward = fastforwardingAllowed
movieControls.allowsDismissal = allowsDismissal
movieControls.translatesAutoresizingMaskIntoConstraints = false
contentOverlayView.addSubview(movieControls)
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
}
}
superview.addSubview(moviePlayer.view)
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
Solved this issue by removing:
moviePlayer.contentOverlayView?.translatesAutoresizingMaskIntoConstraints = false
From the initialization function. Something changed in iOS 16 that created issues using this.