views:

633

answers:

2

I have subclassed UIView object inside a uiscrollview which displays a pdf page. I can zoom that page. But when I do so, the inside view is zoomed and is getting blurred. I understood that the inner view shud be refreshed and i called setNeedsDisplay. But no change have happened and its the same even now. Below is the code for drawRect for the subclassed uiview.

- (void)drawRect:(CGRect)rect
{
if(document)//the pdf document object
{       
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSaveGState(ctx);
    CGContextTranslateCTM(ctx, 0.00, [self bounds].size.height);
    NSLog(@"%f",[self bounds].size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, 
                                                         [self bounds], 0, true));
    CGContextDrawPDFPage(ctx, page);    
    CGContextRestoreGState(ctx);
}
}
+1  A: 

Check out the CATiledLayer example provided by the ScrollViewSuite sample code:

http://developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Introduction/Intro.html

The TapToZoom example illustrates a way to get the view to redraw its content when one zooms in. I.e. you need to somehow set your view's frame to be larger than the screen, or maybe you can also use transforms - however, I never used transforms before.

Efrain
+1  A: 

A bit late to answer, just as pointed out you have to set the frame of subview's each time when zoom is applied. Make sure that you backup the original frame dimensions so that you apply the zoom factor over it.

Scroll view does not change the frame of its subviews when it zooms the subviews, that is why the subview's contents are not refreshed. I found using transforms and others complex, so I just tried the mentioned method, and it worked for me.

Raj