私のアプリは、読み込まれた webview からスクリーンショットを取得する必要があります。画像が保存されたときに時々発生するバグがあります。コンソール ログは次のとおりです。
2013-06-04 20:12:33.093 iBookMark[5895:707] thumbnail img save over
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR> CGImageSourceCreateWithData data parameter is nil
2013-06-04 20:12:48.987 iBookMark[5895:707] [IMKInputSession activate] exception caught.
IMKInputSession: <IMKInputSession: 0x102124cc0> --
NSPortTimeoutException : connection timeout: did not receive reply
2013-06-04 20:12:53.989 iBookMark[5895:707] [IMKInputSession setValue:forTag:] exception caught.
NSPortTimeoutException : connection timeout: did not receive reply
このバグが発生する理由と修正方法を教えてください。ありがとうございます。
更新: これは私のスクリーンショット コードです。
/*the sender is a webView,this function is called in the
WebView's delegate method naming webView: didFinishLoadForFrame:.*/
[sender setMediaStyle:@"screen"];
[sender lockFocus];
NSData* data = [webView dataWithPDFInsideRect:[webView bounds]];
if (data == nil) {
return;
}
[sender unlockFocus];
[sender setMediaStyle:@"savedMediaStyle"];
NSImage *img = [[NSImage alloc] initWithData:data];
[img setCacheMode:NSImageCacheNever];
NSData* imageData = [img TIFFRepresentation];
NSImage* tmpImg = [[NSImage alloc] initWithData:imageData];
[img release];
NSData* pngData = [NSImage compressImage:tmpImg size:NSMakeSize(SmallThumbnailWidth, SmallThumbnailHeight) factor:0.2];
[tmpImg release];
NSString* thumbnailPath = [PathManager getThumbnailPath];
NSString* imageFilePath = [NSString stringWithFormat:@"%@/%ld.png",thumbnailPath,bookmark.bmId];
[pngData writeToFile:imageFilePath atomically:NO];