当我在不同设备上测试我的应用时,我的UIScrollView出现问题。我已经在Iphone 6设备上设置了最大和最小缩放比例,但是当我在Iphone 6 plus或Iphone 5上试用时,我无法弄清楚当我缩放时如何看到我的整个图像不让它再次反弹回来。我真的需要一些帮助才能为不同的设备设置不同的缩放比例。请帮忙!谢谢:))
继承我的scrollview和imageview缩放比例代码:
import UIKit
class DetailViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var myDetailedImageView: UIImageView!
var myDetailedImageName: String?
var nameString: String?
override func viewDidLoad() {
super.viewDidLoad()
func minscale () {
}
scrollView.minimumZoomScale = 0.15
scrollView.maximumZoomScale = 2.0
scrollView.delegate = self
self.myDetailedImageView.image = UIImage(named: myDetailedImageName!)
}
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
return myDetailedImageView
}
// Do any additional setup after loading the view.
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
以下是Iphone 5上的示例:
以下是Iphone 6上应该如何显示的示例: