2

This code doesn't seem to work. wondering what I'm doing wrong/missing. I assume that I: drag and drop the UIPinchGestureRecognizer to the viewcontroller (so that it doesn't interfere with the connections to buttons, label etc. and it is connected to the viewcontroller); then implement this code (make sure connections are proper):

import UIKit

class AlertController: UIAlertController {

@IBAction func scaleImage(sender: UIPinchGestureRecognizer) {
self.view.transform = CGAffineTransformScale(self.view.transform,     sender.scale, sender.scale)
sender.scale = 1
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.blackColor()
}

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

}

Please help !

MontgommeryJR
  • 255
  • 3
  • 18
  • You shouldn't subclass `UIAlertController`. From [the docs](https://developer.apple.com/reference/uikit/uialertcontroller): "The UIAlertController class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified." – keithbhunter Mar 10 '17 at 20:02

1 Answers1

0

You can put your zoomeable UIView inside an UIScrollView an then implement this method

func viewForZooming(in scrollView: UIScrollView) -> UIView? {
    return self.view
}

you need also setup your scrollView delegate and set your self.scrollView.maximumZoomScale > self.scrollView.minimumZoomScale something like this

    self.scrollView.delegate = self
    self.scrollView.maximumZoomScale = 2.0
    self.scrollView.minimumZoomScale = 0.5

then using pitch gesture must scale your `self.view

I hope this helps you, best regards

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55