【发布时间】:2016-09-03 13:49:23
【问题描述】:
我有一个带有图像的 UIScrollView,并且该图像位于容器视图中。视图层次结构如下所示:
UIScrollView
UIView
UIImageView
平移效果很好,但是当我使用捏合手势进行缩放时,图像会改变大小,但不会相对于原点移动,因此两个手指下方的中心点会随着手势的进行而移动。这使得放大特定点变得非常困难,因为它会随着您的缩放而滑开。
所涉及的视图描述:
<MyApp.MyView: 0x7ff6fd827e00; baseClass = UIScrollView; frame = (0 0; 375 667); autoresize = W+H; gestureRecognizers = <NSArray: 0x61800004a4d0>; layer = <CALayer: 0x618000023420>; contentOffset: {684, 487.5}; contentSize: {1731.4584832023011, 1154.3056554682007}>
<UIView: 0x7ff6fbe0c4d0; frame = (0 0; 1728 1152); transform = [2.2028669620902912, 0, 0, 2.2028669620902912, 0, 0]; layer = <CALayer: 0x6180000234c0>>
<UIImageView: 0x7ff6fbe09cd0; frame = (0 0; 1728 1152); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x618000023340>>
我在 UIView 包装器中有 UIImageView,因为我将在图像上覆盖其他需要缩放/缩放图像的视图。
在缩放期间我自己的代码很少运行。 UIScrollViewDelegate 返回 UIView(UIImageView 的父级),并配置滚动视图:
minimumZoomScale = 0.2
maximumZoomScale = 3.0
contentSize = image.size
【问题讨论】:
标签: ios uiscrollview uikit