【问题标题】:UIScrollview error when call UIViewcontroller in landscape mode在横向模式下调用 UIViewcontroller 时出现 UIScrollview 错误
【发布时间】:2016-04-10 22:28:42
【问题描述】:

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

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

UIViewcontroller 被锁定使用:

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

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

这里是项目文件:https://github.com/salvonos/OrientationScrollView

【问题讨论】:

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

标签: ios uiviewcontroller uiscrollview storyboard


【解决方案1】:

解决方法:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    • 2010-12-30
    • 2012-02-05
    • 2011-09-21
    • 1970-01-01
    • 2017-09-16
    相关资源
    最近更新 更多