2

My code for take Snap shot works fine in the iPhone Simulator, but for that code if i use for Device it gives me blank image,

This code is for take snapshot of uiwebview browse the YouTube video

//code for take snap shot

CGSize imageSize = CGSizeZero;

imageSize = [UIScreen mainScreen].bounds.size;

UIGraphicsBeginImageContextWithOptions(imageSize, NO,0);

CGContextRef context = UIGraphicsGetCurrentContext();

for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
    CGContextSaveGState(context);
    CGContextTranslateCTM(context, window.center.x, window.center.y);
    CGContextConcatCTM(context, window.transform);
    CGContextTranslateCTM(context, -window.bounds.size.width * window.layer.anchorPoint.x, -window.bounds.size.height * window.layer.anchorPoint.y);

    if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)])
    {
        [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO];
    }
    else
    {
        [window.layer renderInContext:context];
    }

    CGContextRestoreGState(context);
}

// Retrieve the screenshot image
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Now the Output for iPhone Simulator and for iPhone device

iPhone Simulator ScreenShot

iPhone Simulator ScreenShot

iDevice (iPhone) ScreenShot

iDevice (iPhone) ScreenShot

Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136
g212gs
  • 863
  • 10
  • 26
  • Hi! Are you sure you are taking the snapshot when the UIWebView has finished to load the content? maybe you are taking the snapshot before the content it´s being loaded. In the simulator, the network connection is faster than the use of a carrier (WCDMA-UMTS, GSM, etc.,) it will really depend on that. Put the code in the event webViewDidFinishLoad: and try it again to see if it´s not working. Im assuming the code does what it has to do sure! – AlfuryDB Jul 23 '14 at 13:50
  • Yes, I am sure..., this code is written in following code, - (void)VideoEnterFullScreen:(id)sender{} // method called when webview plays YouTube video (i.e.) video play in full screen mode,it is notification i use this code, it works fine on the simulator, but for iDevice it only captures media player controls not video. – g212gs Jul 24 '14 at 04:34

0 Answers0