Swift:为什么我的截图没有显示Avplayer视频?

时间:2017-02-07 08:56:35

标签: ios swift screenshot

在我的项目中,我在嵌入式视图中使用了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)

问题是当我在模拟器中运行上面的代码时它运行良好但在物理设备中它返回黑色图像

任何建议都会有所帮助

Simulator screenshot

iPad截图: ipad screenshot

1 个答案:

答案 0 :(得分:1)

请参阅此链接中的第二个答案 Screenshot for AVPlayer and Video