UIScrollView的内容大小 [英] content size of UIScrollView

查看:154
本文介绍了UIScrollView的内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIScrollView ,其中我将 contentSize 设置为最初的屏幕大小。这是否意味着如果我在滚动视图中有一个 UIImageView ,那么它的缩放比 contentSize 更大>我订了?

I have a UIScrollView in which I've set the contentSize to the size of the screen initially. So does this mean that if I have an UIImageView inside the scroll view then it can't zoom bigger than the contentSize I've set?

因为我最初有 UIScrollView ,其中 contentSize 手机的尺寸,当我放大图像时,它做得很好(我可以看到 contentSize 随着我放大而变大)但是当我手动调整它时不能。这是为什么?

Because I initially have a UIScrollView with a contentSize of the phone's dimension and when I zoom into an image, it does it just fine (I can see the contentSize grows bigger as I zoom in) but when I adjust it manually it can't. Why is this?

我认为当我最初初始化 UIScrollView 框架时,内容大小将设置为帧的大小,但它可以在我放大时动态增长。但是当我尝试设置 contentSize 时,它似乎现在已经修复了。我问这个的原因是因为我在 UIScrollView 中有一个 UIImageView ,当我放大图像时我旋转图像,我希望 contentSize 重置。问题是如何重置?

I think when I initially initialize the UIScrollView frame, the content size will be set to the frame's size, however it can grow dynamically as I zoom in. However when I try to set the contentSize, it seems that now it's fixed. The reason why I am asking this is because I have a UIImageView inside a UIScrollView, when I zoom in on the image and I rotate the image, I want the contentSize to reset. Question is how do I reset this?

推荐答案

缩放级别由 zoomScale UIScrollView 的属性。其最大值和最小值分别由 maximumZoomScale minimumZoomScale 设置。

The zoom level is set by the zoomScale property of the UIScrollView. Its maximum and minimum is set by maximumZoomScale and minimumZoomScale respectively.

如果您尝试通过设置 contentSize 来设置缩放,那么您做错了。 contentSize 应设置为缩放比例为 1.0 ,然后你只需设置 zoomScale 属性是您想要的属性,例如 2.0 如果您希望它放大到200%。

If you're trying to set the zoom by setting the contentSize then you're doing it wrong. The contentSize should be set as if the zoom scale was 1.0 and then you'd just set the zoomScale property to be what you wanted so for example 2.0 if you wanted it zoomed in to 200%.

您可能会在缩放时看到 contentSize 更改,因为我认为滚动视图会将其缩放到当前缩放比例。

You're probably seeing contentSize change as you zoom because I think the scroll view reports it scaled to the current zoom scale.

这篇关于UIScrollView的内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆