I would like to implement only uiscrollview zoom function in iphone sdk. Is it possible to do this?

I would like to implement only zoom function in uiscrollview in iphone sdk. Is it possible to do this?

I am using the following code

{
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 700, 510)];
   scrollView.delegate = self;
   scrollView.ScrollEnabled=YES;
   scrollView.contentSize = CGSizeMake(700, 510);
   scrollView.userInteractionEnabled = FALSE;
   scrollView.clipsToBounds = YES;
   scrollView.minimumZoomScale = 1;
   scrollView.maximumZoomScale = 2;
   [scrollView addSubview:portrateSlideImage];
   [portSlideContainer addSubview:scrollView];

      

}

And using uiscrollview delagte

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return portrateSlideImage;
}

      

0


source to share


1 answer


Try it. Maybe this will help you.

Remove the line from the code where you set the maximum scroll scale.

{
   scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 700, 510)];
   scrollView.delegate = self;
   scrollView.ScrollEnabled=YES;
   scrollView.contentSize = CGSizeMake(700, 510);
   scrollView.userInteractionEnabled = TRUE;         //edited again
   scrollView.clipsToBounds = YES;
   scrollView.minimumZoomScale = 1;
   scrollView.maximumZoomScale = 2;                  //edited again
   [scrollView addSubview:portrateSlideImage];
   [portSlideContainer addSubview:scrollView];
}

      



And add this function

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
   scrollView.minimumZoomScale = scale;
}

      

It won't let you zoom out

. Just increase

0


source







All Articles