1
나는 아이폰 SDK에 멍청하다.iPhone CatiledLayer pdf
저는 CatiledLayer를 사용하여 사용자 정의 PDF를 읽으려고 시도하지만 많은 문제가 있습니다. 나는 그래서 동적 페이지를 그릴하려고하지만 draw 함수의 코드가 작동하지 않는 PDF 문서의 모든 페이지를로드 할 수 없습니다 :
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextSaveGState(ctx);
for(int i=0; i<4;i++)
{
CGContextRestoreGState(ctx);
CGContextSaveGState(ctx);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx, -layer.bounds.size.width*((5-2*i)/12), layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform([[pages objectAtIndex:i] pagin], kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx, [[pages objectAtIndex:i] pagin]);
}
}
이 기능 인쇄 마지막 페이지를.
어떤 아이디어? '
매직 넘버가 올바른 일 아닌가요 rigth 코드는 다음과 같습니다
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
//scrollView.scrollEnabled=NO;
//scrollView.alpha=0.2;
//[scrollView setContentOffset:scrollView.contentOffset animated:YES];
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
if(attua==1)
{
CGContextSaveGState(ctx);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx,layer.bounds.size.width*1/(2*[pages count]) -layer.bounds.size.width*[pages count]/(2*[pages count]), layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform([[pages objectAtIndex:0] pagin], kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx, [[pages objectAtIndex:0] pagin]);
CGContextRestoreGState(ctx);
}
for(int i=1; i<[pages count];i++)
{ //myContentView.frame=CGRectMake(0, 0,800*i, 1024);
if(i>attua-2)
{
if(i<attua+2)
{
CGContextSaveGState(ctx);
CGContextTranslateCTM(ctx,layer.bounds.size.width*(i*2+3/2)/(2*[pages count]) -layer.bounds.size.width*[pages count]/(2*[pages count]), layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform([[pages objectAtIndex:i] pagin], 0, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx,[[pages objectAtIndex:i] pagin]);
CGContextRestoreGState(ctx);
}
}
}
scrollView.scrollEnabled=YES;
}
이제 모든 작업!