tags:

views:

84

answers:

0

I want to apply tap (double click) zoom and patch (figure) zoom on my web view. I am given below my code.

    -(void)loadPdf:(int)pageno{

      myPageRef = CGPDFDocumentGetPage(myDocumentRef, pageno);


  CGRect pdfcropBox =  CGPDFPageGetBoxRect(myPageRef,kCGPDFCropBox);
  CGRect pdfcropBox1;
  pdfcropBox1.origin.x=0;
  pdfcropBox1.origin.y=0;
  pdfcropBox1.size.width=scrrollPotrait.frame.size.width;
  pdfcropBox1.size.height=pdfcropBox.size.height;

 CATiledLayer *tiledLayer = [CATiledLayer layer];
    tiledLayer.delegate = self;
    tiledLayer.tileSize = CGSizeMake(1024, 1024);
    tiledLayer.levelsOfDetail = 10;
    tiledLayer.levelsOfDetailBias = 2;
    tiledLayer.frame =self.view.frame;

// tiledLayer.masksToBounds=YES;

    CGRect pageScrollViewFrame = CGRectMake(((pageno - 1) * scrrollPotrait.frame.size.width), 
                                        0, 
                                        scrrollPotrait.frame.size.width, 
                                        scrrollPotrait.frame.size.height);

pageScrollView = [[UIScrollView alloc] initWithFrame:pageScrollViewFrame];

[pageScrollView setTag:pageno];
[pageScrollView setDelegate:self];

[pageScrollView setMinimumZoomScale:1.0];
[pageScrollView setMaximumZoomScale:6.0];

[pageScrollView setClipsToBounds:NO];



[pageScrollView setContentSize:CGSizeMake(scrrollPotrait.frame.size.width * 1, scrrollPotrait.frame.size.height)];

UIView *myContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scrrollPotrait.frame.size.width,scrrollPotrait.frame.size.height)];

[myContentView.layer addSublayer:tiledLayer];



UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleDoubleTap)];
singleFingerDTap.numberOfTapsRequired = 1;
[myContentView addGestureRecognizer:singleFingerDTap];
[singleFingerDTap release];


[pageScrollView addSubview:myContentView];

[scrrollPotrait addSubview:pageScrollView];


}

- (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);
}


 - (UIView *)viewForZoomixngInScrollView:(UIScrollView *)scrollView{
    return [scrollView.subviews objectAtIndex:pageControl.currentPage];
}

in a view did load I intialized scrool view

 scrrollPotrait.contentSize = CGSizeMake(scrrollPotrait.frame.size.width * totalPages, scrrollPotrait.frame.size.height);
scrrollPotrait.showsHorizontalScrollIndicator = NO;
scrrollPotrait.showsVerticalScrollIndicator = NO;
scrrollPotrait.scrollsToTop = NO;
scrrollPotrait.minimumZoomScale = .1;   
scrrollPotrait.maximumZoomScale = 1.0; 
scrrollPotrait.delegate = self;

Please give me a hint or any document. Thanks in advanced.