简体   繁体   English

Swift 3-在方向更改时翻转整个屏幕/视图

[英]Swift 3 -Flip entire screen/view On Orientation change

I need to a way to constantly monitor if the user has rotated the iPad. 我需要一种方法来不断监视用户是否旋转了iPad。

UserDidRotate() {

    if(orientation = portrait.upsideDown){

        //
        //Code that will Present View upside down...
        //
    }
        else if(orientation = portrait){

        //
        //Code that will Present View right side up...
        //
    }
}

How can I check for orientation change and also manually present the view upside down for my Swift 3 app? 如何查看我的Swift 3应用的方向变化并手动将视图倒置显示?

EDIT: 编辑:

I have tried: 我努力了:

override func viewWillTransition(to size: CGSize, with coordinator: 
UIViewControllerTransitionCoordinator){} 

and that method is never hit. 而且这种方法永远不会成功。

尝试:

self.view.transform = self.view.transform.rotated(by: CGFloat(M_PI))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM