2016-01-06 188 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! 
     } 
相關問題