webview から画像をレンダリングしています。そのため、renderIncontext メソッドは for ループで 50 回以上呼び出します。20 回または 30 回実行した後、メモリの消費量が増えたため、アプリがクラッシュしました。
私はこのコードを使用しました:
UIGraphicsBeginImageContext(CGSizeMake([w floatValue], [h floatValue]));
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, webview.frame);
[self.webview.layer renderInContext:ctx];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
20回後にクラッシュしました。その解決策が必要です。
なぜこれが起こるのですか?誰でも知っていますか?