2016-01-06 202 views
0

我有一个UIScrollview,它装载了其他两个UIViewControllers。主要的UIViewcontroller的方向锁定到肖像模式,最后一个视图有一个按钮,可调用另一个uiviewcontroller,其中UIImageview需要根据移动方向旋转。在横向模式下调用UIViewcontroller时出现UIScrollview错误

一切工作正常,但如果我在横向模式下旋转移动,然后按下按钮调用UIViewcontroller与其中的图像,UIScrollview显示中途或从页1当我从图像返回到主滚动视图。

override func shouldAutorotate() -> Bool { 
     return false 
    } 

    override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
     return UIInterfaceOrientationMask.Portrait 
    } 

这里的项目文件:

主要UIViewcontroller使用锁定https://github.com/salvonos/OrientationScrollView

enter image description here

enter image description here

+0

无法下载项目文件。 – thndrkiss

+0

对不起改了链接 – SNos

+0

该项目为空 – kholl

回答

0

解决使用:

var autoRotate: Bool? 
    var orientationMode: UIInterfaceOrientationMask? 

    override func viewDidLoad() { 
      super.viewDidLoad() 

      autoRotate = false 
      orientationMode = UIInterfaceOrientationMask.Portrait 
    } 


    override func viewWillAppear(animated: Bool) { 
     super.viewWillAppear(animated) 

     self.autoRotate = true 
     self.orientationMode = UIInterfaceOrientationMask.All 
    } 


    override func shouldAutorotate() -> Bool { 
      return autoRotate! 
     } 


     override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
      return orientationMode! 
     } 
相关问题