content size of UIScrollView(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?
推荐答案
缩放级别由 UIScrollView
的 zoomScale
属性设置.其最大值和最小值分别由 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 的内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView 的内容大小


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01