iphone uiscrollview 和 uiimageview - 设置初始缩放

iphone uiscrollview and uiimageview - setting initial zoom(iphone uiscrollview 和 uiimageview - 设置初始缩放)
本文介绍了iphone uiscrollview 和 uiimageview - 设置初始缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将图像加载到滚动视图中.图像始终以 100% 缩放加载.有没有办法将其设置为加载到另一个缩放级别,比如 0.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 - 设置初始缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
NSURLSessionTaskPriority seems to be ignored?(NSURLSessionTaskPriority似乎被忽略了?)
How to make dataWithEPSInsideRect vector rather than bitmap in vector format?(如何用EPSInside Rect将dataWithEPSInside Rect变成矢量而不是位图的矢量格式?)