Is it possible to capture a screenshot of a whole webpage in the iOS Simulator?

1.2k views Asked by At

Currently i am making "traditional" screenshots and combine them using a graphics editor to show the full webpage at once. Is there any more efficient way of making screenshots of a full webpage, just as by using Awesome Screenshot for Google Chrome?

(No, i do not have an iPhone ;)

2

There are 2 answers

1
Jakub On

You have to write it on your own.

  1. Create a fullscreen webView inside your app.
  2. Open page you want to open
  3. Manipulate the property webView.scrollView to move successfully to the bottom of the page.
  4. Capture screenshot every time
  5. If you're on the bottom merge screenshots to one large images.

I believe this is a simplest way and run on the simulator.

0
Nithin Michael On

See the code below.

-(NSData *)getImageFromView:(UIView *)view  // Mine is UIWebView but should work for any
{
    NSData *pngImg;
    CGFloat max, scale = 1.0;
    CGSize viewSize = [view bounds].size;
// Get the size of the the FULL Content, not just the bit that is visible
CGSize size = [view sizeThatFits:CGSizeZero];

// Scale down if on iPad to something more reasonable
max = (viewSize.width > viewSize.height) ? viewSize.width : viewSize.height;
if( max > 960 )
    scale = 960/max;

UIGraphicsBeginImageContextWithOptions( size, YES, scale );

// Set the view to the FULL size of the content.
[view setFrame: CGRectMake(0, 0, size.width, size.height)];

CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];    
pngImg = UIImagePNGRepresentation( UIGraphicsGetImageFromCurrentImageContext() );

UIGraphicsEndImageContext();
return pngImg;    // Voila an image of the ENTIRE CONTENT, not just visible bit

}

I got this code from this link. Hope it will help you.