在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

有什么建议吗?谢谢。

最佳答案

将委托代码分解为扩展名:

class PlayerViewController: UIViewController {
}
@available(iOS 9.0, *)
extension PlayerViewController: AVPictureInPictureControllerDelegate {
}

关于ios - 如何仅在委托(delegate)(继承)中快速指定可用性?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33277559/

10-14 22:34
查看更多