你好,这是我在CATiledlayer中绘制pdf的代码
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx, myPageRef);
}
Run Code Online (Sandbox Code Playgroud)
一切都很好但我在下面的行中得到了内存泄漏警告
CGContextDrawPDFPage(ctx, myPageRef);
Run Code Online (Sandbox Code Playgroud)
这里的myPageRef是CGPDFPageRef
我从github下载了代码并进行了一些研发,发现,
我忘了CGPDFPageRelease(myPageRef)在dealloc我的TiledView方法中发布..
写完这段代码后我的内存泄漏就解决了....
// Clean up.
- (void)dealloc {
CGPDFPageRelease(myPageRef);
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3227 次 |
| 最近记录: |