iPhone CatiledLayer pdf
<p>i'm a noob in IPhone sdk.</p>

<p>I try to develop a custom pdf read using CatiledLayer but i've many problem.
I can't load all the pages of pdf document so i try to draw dynamically the pages but this code  of draw function don't work:</p>

<pre><code>- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
 CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
 CGContextSaveGState(ctx);  
 for(int i=0; i&lt;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]);

 }
}
</code></pre>

<p>this function print only the last page.</p>

<p>Any idea?'</p>

<p>the magic number is't correct
the rigth code is:</p>

<pre><code>- (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&lt;[pages count];i++)

    {           //myContentView.frame=CGRectMake(0, 0,800*i, 1024);


        if(i&gt;attua-2)
        {
            if(i&lt;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;







}
</code></pre>

<p>Now all work !!</p>
