swift - AVPlayerViewController 在展开后不会释放

标签 swift segue tvos unwind-segue deinit

在我的 tvOS 应用程序中,我有一个 AVPlayerViewController,通过显示转场呈现,如果没有找到视频,它会显示警报并展开到上一个 View 。我创建一个警报 Controller ,呈现它,并在警报操作处理程序上调用展开转场。一切似乎都按预期工作,但我发现展开的 View Controller 没有被释放。

let noVideosAlertController = UIAlertController(title: "No Videos Configured", message: "No videos are configured for this bank. Log into the OEC and select Lobby Display to add videos to your playlist.", preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "OK", style: .Default) { [weak self] (alert) in
    self?.performSegueWithIdentifier("unwindToConfig", sender: self!)
}

noVideosAlertController.addAction(alertAction)
presentViewController(noVideosAlertController, animated: true, completion: nil)

我发现,如果我不调用展开并手动按菜单按钮返回,它会很好地取消分配,因此有关展开转场的某些内容不允许玩家被取消分配。我还尝试用 dismissViewControllerAnimated 替换展开转场,它似乎会关闭播放器,但仍然没有解除分配。

最佳答案

使用一个几乎空的文件进行测试后,该文件仅加载、显示警报并在警报操作处理程序上展开,它解除分配得很好。我将其跟踪到 AVPlayerViewController 的 viewDidDisappear 方法,我重写该方法来进行一些清理。将其更改为 viewWillDisappear 解决了我的问题,但我不确定原因。

关于swift - AVPlayerViewController 在展开后不会释放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38447224/

相关文章:

ios - 如何检查数组中连续的工作日

Storyboard Segue 未调用 iOS 协议(protocol)方法

uisearchbar - 在 tvOS 上的 UISearchController 上禁用模糊背景

json - Swift 4 Codable 解码数组用引号括起来

swift - Core Data (Magical Record) + WatchKit Extension + Cocoa Touch Framework

ios - 在 Collection View 中执行 numberof sections 时崩溃

swift - 导航和标签栏随着 Push Segue 消失

ios - 单个 View Controller 的多个按钮

xcode - tvos:Alamofire 框架的 iTunesConnect 验证失败:不包含位码

swift - 按下 Siri 远程菜单按钮停止视频播放