是否可以在iOS模拟器中捕获整个网页的屏幕截图?
目前,我正在制作“传统”截图,并使用图形编辑器将它们组合起来,一次显示整个网页。有没有比谷歌Chrome更有效的方法来制作完整网页的截图是否可以在iOS模拟器中捕获整个网页的屏幕截图?,ios,iphone,objective-c,ios-simulator,webpage-screenshot,Ios,Iphone,Objective C,Ios Simulator,Webpage Screenshot,目前,我正在制作“传统”截图,并使用图形编辑器将它们组合起来,一次显示整个网页。有没有比谷歌Chrome更有效的方法来制作完整网页的截图 (不,我没有iPhone;)你必须自己写 在应用程序中创建全屏webView 打开要打开的页面 操纵webView.scrollView属性以成功移动到页面底部 每次截图 如果您位于底部,请将屏幕截图合并到一个大图像中 我相信这是一种最简单的方法,可以在模拟器上运行。请参阅下面的代码 -(NSData *)getImageFromView:(UIView *)
(不,我没有iPhone;)你必须自己写
webView
-(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
}
我从林克那里得到了这个密码。希望它能帮助您。我没有开发移动应用程序的经验,我只想测试一个网站,而不是一个移动应用程序。但是,如果您的解决方案有效,您可以为此目的开发一个应用程序。