iphone uiscrollview和uiimageview - 设置初始缩放 [英] iphone uiscrollview and uiimageview - setting initial zoom
本文介绍了iphone uiscrollview和uiimageview - 设置初始缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码将图像加载到滚动视图中。图像始终以100%变焦加载。有没有办法将其设置为加载到另一个缩放级别,比如说.37?
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?
我试过scrollView.zoomScale = .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];
推荐答案
我想通了......我正在使用scrollView .zoomScale = 0.37;在我加载图像之前更改了代码并且它工作得很好。
I figured it out... I was using scrollView.zoomScale = 0.37; before I loaded the image changed code and it works great.
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];
scrollView.zoomScale = .37;
这篇关于iphone uiscrollview和uiimageview - 设置初始缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文