Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在横向模式下调用UIViewcontroller时发生UIScrollview错误_Ios_Uiviewcontroller_Uiscrollview_Storyboard - Fatal编程技术网

Ios 在横向模式下调用UIViewcontroller时发生UIScrollview错误

Ios 在横向模式下调用UIViewcontroller时发生UIScrollview错误,ios,uiviewcontroller,uiscrollview,storyboard,Ios,Uiviewcontroller,Uiscrollview,Storyboard,我有一个UIScrollview,它与另外两个UIViewController一起加载。主UIViewcontroller的方向锁定为纵向模式,最后一个视图有一个按钮,可以调用另一个UIViewcontroller,该按钮带有UIImageview,需要根据移动方向旋转 一切正常,但如果我在横向模式下旋转手机,然后按下按钮调用带有图像的UIViewcontroller,则当我从图像返回到主滚动视图时,UIScrollview会显示一半或从第1页开始 主UIViewcontroller通过以下方式

我有一个
UIScrollview
,它与另外两个
UIViewController一起加载。主
UIViewcontroller
的方向锁定为纵向模式,最后一个视图有一个按钮,可以调用另一个
UIViewcontroller
,该按钮带有
UIImageview
,需要根据移动方向旋转

一切正常,但如果我在横向模式下旋转手机,然后按下按钮调用带有图像的
UIViewcontroller
,则当我从图像返回到主滚动视图时,
UIScrollview
会显示一半或从第1页开始

UIViewcontroller
通过以下方式锁定:

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

    override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Portrait
    }
此处显示项目文件:

使用以下方法解决:

    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!
        }

无法下载项目文件。抱歉,更改了链接项目为空。现在应该可以了