2017-03-10 2 views
0

이 코드는 작동하지 않습니다. 내가 잘못하고있는 것을 궁금해하거나 실종. 나는 그것을 가정한다. UIPinchGestureRecognizer를 viewcontroller에 드래그 앤 드롭한다. (버튼, 라벨 등의 연결을 방해하지 않고 viewcontroller에 연결된다.); 이 코드를 구현하십시오 (연결이 적절한 지 확인하십시오).전체 화면 (라벨, 버튼 및 이미지 포함)을 확대/축소하려면 어떻게해야합니까? IOS, Swift 3

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() 
} 

} 

도와주세요!

+0

당신은'UIAlertController'를 하위 클래스 화해서는 안됩니다. [the docs] (https://developer.apple.com/reference/uikit/uialertcontroller)에서 : "UIAlertController 클래스는 그대로 사용되며 하위 클래스 화를 지원하지 않습니다.이 클래스의 뷰 계층 구조는 private이며 수정해서는 안된다. " – keithbhunter

답변

0

당신은

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

당신은 또한 설정하여있는 ScrollView 대리자를 필요로하고이

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

처럼 self.scrollView.maximumZoomScale>self.scrollView.minimumZoomScale 뭔가를 설정 한 후 사용하여 다음 구현있는 UIScrollView 내부에이 방법을 당신의 zoomeable의 UIView를 넣을 수 있습니다 피치 제스쳐는`self.view를 조절해야합니다.

나는 이것이 당신을 돕기를 바랍니다,