1

My application is going to support PIP in AVPlayer after iOS 9 but I still want to keep my app working in iOS 7 and above. I read this post regarding with the availability check. But it seems not working for my case. For example:

My code:

class PlayerViewController: UIViewController, AVPictureInPictureControllerDelegate

This works fine in iOS 9, but how to make it works in iOS 7 and above? I can't do this:

   @available(iOS 9.0, *)
   class PlayerViewController: UIViewController, AVPictureInPictureControllerDelegate
   @available(iOS 7.0, *)
   class PlayerViewController: UIViewController

Any suggestion? Thanks.

Community
  • 1
  • 1
Bagusflyer
  • 12,675
  • 21
  • 96
  • 179

1 Answers1

3

Break the delegate code into an extension:

class PlayerViewController: UIViewController {
}
@available(iOS 9.0, *)
extension PlayerViewController: AVPictureInPictureControllerDelegate {
}
Gary Makin
  • 3,109
  • 1
  • 19
  • 27