ios - UIScrollView.contentSize 似乎随着缩放而增长

标签 ios uiscrollview scroll zooming

所以我的 scrollView 的 contentSize 最初等于我的图像的框架,但似乎我缩放得越多,contentSize 就越大。因此,当 scrollView 放大时,它周围有一个巨大的间隙。动态更新 - (void)scrollViewDidZoom:(UIScrollView *)aScrollView 中的 contentSize 似乎不起作用。我错过了什么吗?

注意:间隙仅在垂直方向可见(即:imageView 的上方和下方)

最佳答案

我不认为可以在缩放 时动态更新contentSize。这是因为:

A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.

(Apple docs)

您应该根据zoomScale更新您的contentSize用户完成缩放后使用:

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView 
                       withView:(UIView *)view 
                        atScale:(float)scale

关于ios - UIScrollView.contentSize 似乎随着缩放而增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11785613/

相关文章:

ios - 如何滚动到对象的中心位置

iphone - 使用 UIScrollView 和 UITextFields 作为 subview 进行不需要的自动滚动

html - 表格不会在行上使用鼠标滚轮滚动,仅在滚动条上滚动

ios - 为什么 ARC 的 objc_autoreleaseReturnValue 的实现对于 x86_64 和 ARM 不同?

ios - VectorKit MapKit 堆栈溢出崩溃

ios - 访问另一个类中的 ScrollView 委托(delegate)方法

objective-c - 显示键盘时无法与 ScrollView 中的(某些)UI 元素交互

javascript - 有没有办法使用 mootools 在鼠标接近其边界时使窗口滚动?

iphone - 从左向右翻转iOS 4之前的UIView

ios - 如何: Debug UIWindows were created prior to initial application activation