Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
466 views
in Technique[技术] by (71.8m points)

objective c - iphone uiscrollview and uiimageview - setting initial zoom

I use the following code to load an image into an scroll view. The image always loads at 100% zoom. Is there a way to set it to load to another zoom level, say .37?

I have tried scrollView.zoomScale = .37 but it didnt seem to work

UIImageView *tempImage = [[UIImageView alloc]initWithImage:[UIImage imageWithData:data]];
        self.imageView = tempImage;

        scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height);
        scrollView.maximumZoomScale = 1;
        scrollView.minimumZoomScale = .37;
        scrollView.clipsToBounds = YES;
        scrollView.delegate = self;

        [scrollView addSubview:imageView];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Zooming only works when you implement the viewForZoomingInScrollView: delegate callback.

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll {
  return imageView;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...