我的应用程序将在iOS 9之后支持AVPlayer中的PIP,但我仍然想让我的应用程序在iOS 7及更高版本中运行。关于可用性检查,我阅读了this post。但它似乎不适合我的情况。例如:
我的代码:
class PlayerViewController: UIViewController, AVPictureInPictureControllerDelegate
这在iOS 9中运行良好,但如何使其在iOS 7及更高版本中运行?我不能这样做:
@available(iOS 9.0, *)
class PlayerViewController: UIViewController, AVPictureInPictureControllerDelegate
@available(iOS 7.0, *)
class PlayerViewController: UIViewController
有什么建议吗?感谢。
答案 0 :(得分:3)
将代理代码分解为扩展名:
class PlayerViewController: UIViewController {
}
@available(iOS 9.0, *)
extension PlayerViewController: AVPictureInPictureControllerDelegate {
}