Xcode 8升级后,缩放不起作用

时间:2016-09-22 14:41:37

标签: ios swift uiscrollview pinchzoom

我使用Swift。将我的Xcode升级到版本8后,viewForZoomingInScrollView无效。我的缩放代码在更新的Xcode之前工作良好。这是我的代码。

import UIKit

class ViewController: UIViewController,UIScrollViewDelegate
{
    /*ScrollView Zoom Code 01*/
    @IBOutlet var scrollView: UIScrollView!
    @IBOutlet var imageView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        /*ScrollView Zoom Code  02*/
        self.scrollView.minimumZoomScale = 1.0
        self.scrollView.maximumZoomScale = 6.0
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    /*ScrollView Zoom Code  03*/
     func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView?
    {
        return imageView
    }
}

Xcode建议使用新代码,但是当我在iPhone上运行时,它无法进行缩放:

Xcode suggest new code but also it does not work zooming when I running on my iPhone

1 个答案:

答案 0 :(得分:6)

将您的方法替换为func viewForZooming(in scrollView: UIScrollView) -> UIView?,应该使用此方法。