UIScrollView cannot display image either in Portrait or Landscape mode

I have created a VC with orientation in Landscape in storyboard

I have added an UIIScrollView in it , say, make it: (w)1000, 500 (h) in the VC.

What I wanted to do:

1) Scrolling the image (with high resolution like 1334 x 750) inside ScrollView
2) view the image in ScrollView in landscape mode


To make ScrollView to display the image, I have to do it in `viewDidAppear` 

but here the Problems:

1) The Width and height of the `ScrollView` is gone
2) label on top gone.
3) The `ScrollView` Size become small something like 200 x 150 and start from the Top corner like (0,0)
What I need to do to make `scrollview` size like before 1000 x 500? --- Update --
class ViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var myUIScrollView: UIScrollView! var imgView: UIImageView! override func viewDidLoad() { super.viewDidLoad() //-- force to landscape mode: let value = UIInterfaceOrientation.LandscapeLeft.rawValue UIDevice.currentDevice().setValue(value, forKey: "orientation") self.myUIScrollView.maximumZoomScale = 10.0 self.myUIScrollView.minimumZoomScale = 1.0 self.myUIScrollView.delegate = self imgView = UIImageView(image: UIImage(named: "MyPhoto.png")) } override func viewDidAppear(animated: Bool) { self.myUIScrollView.contentSize = imgView.bounds.size self.myUIScrollView.addSubview(imgView) view.addSubview(myUIScollView) } override func shouldAutorotate() -> Bool { return true } func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? { return imgView }
链接地址: http://www.djcxy.com/p/74274.html

上一篇: UIView缺少背景

下一篇: UIScrollView无法以纵向或横向模式显示图像