所以我的 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.
您应该根据zoomScale
更新您的contentSize
在用户完成缩放
后使用:
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView
withView:(UIView *)view
atScale:(float)scale
关于ios - UIScrollView.contentSize 似乎随着缩放而增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11785613/