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