Swift:为什么我的屏幕截图无法显示Avplayer视频?

3

在我的项目中,我在嵌入的视图中使用了AVPlayerViewController,并允许用户在视频上进行绘画。为了截取屏幕截图,我使用了以下代码...

UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen().bounds.size, false, 0);
            self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
            var image:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)

问题在于当我在模拟器中运行上述代码时,它能正常工作,但在实际设备上返回黑色图像。
如有建议,请提出。 模拟器截图 iPad 截图: iPad 截图
1个回答

1

即使将其更改为false/1.0,它在iPad上仍然返回黑屏,但在模拟器中运行良好。 - Raghuram
请查看此链接中的第二个答案:https://dev59.com/x2Ag5IYBdhLWcg3ws8vo - Pranav Pravakar
它只捕获视频而不是UIView。我需要UIView和视频。@ Pranav Pravakar - Raghuram

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接