Home > Net >  How to prevent ARSCNView from rotating
How to prevent ARSCNView from rotating

Time:11-21

I have a class as below

class ViewController: UIViewController, ARSCNViewDelegate, SCNPhysicsContactDelegate  {

    @IBOutlet var sceneView: ARSCNView!

How to prevent the sceneView from rotating?

I tried many ways such as

add

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
           return UIInterfaceOrientationMask.portrait
       }
     
       override var shouldAutorotate: Bool {
           return false
       }

in UIViewController

Or add

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
    {
       
        return UIInterfaceOrientationMask.portrait
    }

in App delegate

Or set enter image description here

Or set enter image description here all don't work.

When I run it on my ipad, it always rotates when I change my ipad orientation.

CodePudding user response:

If you want to prevent rotation in all your code, you can try: go in the info.plist, go to "Supported interface orientation (iPad)" or "Supported interface orientation (iPhone)", open a section up with the disclosure triangle and delete the items you don't want to rotate to for the iPad/iPhone.

  • Related