7
votes

Edit: I have controller containing uiscrollview. That scrollview contains custom uiview having its separate class inherited from uiview. That uiview has uiimageview as subview. No i am taking "(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView" in main controller. But that method didn't get fire when i zoom scrollview. What should i do so that this method may get called.

UIView *DrawingPlusImageView = [[UIView alloc]initWithFrame:CGRectMake((i*IMAGEVIEW_IPAD_LAND_X+112), 0, 800, 600)];

    IDDrawingView *drawView = [[IDDrawingView alloc]initWithFrame:CGRectMake(0, 0, 800, 600)];

    UIImageView* imgViewLand = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)];
    [imgViewLand setImage:[UIImage imageNamed:@"noFileSelected.png"]];
    [drawView setImageToDraw:imgViewLand.image];
    //        drawView.delegate = self;
    [drawView setCurrentSlidId:hmslide.strSlideID];
    [DrawingPlusImageView addSubview:imgViewLand];
    [DrawingPlusImageView addSubview:drawView];


    [scrollViewPresentation addSubview:DrawingPlusImageView];
    drawView.userInteractionEnabled = YES;

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
// Return the view that we want to zoom

return  [self.scrollViewPresentation.subviews objectAtIndex:1];// there are slides, im zooming the second
}
2

2 Answers

21
votes

I was having the same problem. and setting the minimum and maximum zoom levels for ScrollView solved my problem..try

self. scrollViewPresentation.minimumZoomScale = 1.0;
self. scrollViewPresentation.maximumZoomScale = 10.0;
0
votes

It's only called once you begin to zoom. The view should be a subview of the scrollview, keep a reference to it as a property and return that in the delegate method:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.view addSubview:self.scrollView];
    [self.scrollView addSubview:self.container];
    [self.container addSubview:self.imageView];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageView;
}