3

In my project i used AVPlayerViewController in an embedded view.And allow user to draw on the video.To take a screenshot i used the below code...

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

The problem is when i run the above code in simulator it works well but in Physical device it returns black image

Any suggestion would be helpful

Simulator screenshot

iPad screenshot: ipad screenshot

Raghuram
  • 1,651
  • 2
  • 12
  • 17

1 Answers1

1

Please see the 2nd answer in this link Screenshot for AVPlayer and Video

Community
  • 1
  • 1
Pranav Pravakar
  • 205
  • 3
  • 7
  • Even after changing to false/1.0 it returns black screen in iPad but it works well in simulator – Raghuram Feb 07 '17 at 11:45
  • Please see the 2nd answer in this link [http://stackoverflow.com/questions/23286252/screenshot-for-avplayer-and-video](http://stackoverflow.com/questions/23286252/screenshot-for-avplayer-and-video) – Pranav Pravakar Feb 08 '17 at 06:55
  • It captures the video alone not the UIView.I need both UiView and Video @ Pranav Pravakar – Raghuram Feb 08 '17 at 10:06