在UIScrollView中捏合时,图像只是向下跳跃然后向左,然后整个ScrollView冻结

时间:2015-12-14 19:47:11

标签: ios swift imageview scrollview

所以我有一个scrollView和一个图像视图里面,一切都很好(滚动),直到我尝试捏缩放时,整个图片只是跳到向下和向左,并保持相同的大小,但当我举起手指scrollView只是冻结,即使滚动停止工作。这是代码:

class ScrollViewViewController: ViewController, UIScrollViewDelegate {

@IBOutlet weak var scrollView: UIScrollView!

var imageView = UIImageView()
var image = UIImage() {
    didSet {imageView.image = image}
}

override func viewDidLoad() {
    super.viewDidLoad()

    let imageView = UIImageView(image: image)
    imageView.frame = CGRect(origin: CGPointZero, size: image.size)
    scrollView?.addSubview(imageView)
    scrollView?.contentSize = imageView.frame.size
    scrollView?.delegate = self
    scrollView?.minimumZoomScale = 0.5
    scrollView?.maximumZoomScale = 2
}

func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
    return imageView
}
}

有人发现任何潜在的问题吗?

0 个答案:

没有答案