How to constrain autorotation to a single orientation for some views, while allowing all orientations on others?

The short answer is that you’re using UINavigationController, and that won’t work like you want it to. From Apple’s docs: Why won’t my UIViewController rotate with the device? All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set. To make sure that all your child view controllers rotate … Read more

How to check if device orientation is landscape left or right in swift?

you can do something like, if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft{ } else if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight{ } else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortraitUpsideDown{ } else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortrait{ } SWIFT 5 if UIDevice.current.orientation.isLandscape { } else if UIDevice.current.orientation.isFlat { } else if UIDevice.current.orientation.isPortrait { } else if UIDevice.current.orientation.isValidInterfaceOrientation { } SWIFT 3 if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft … Read more

Responsive site is zoomed in when flipping between Portrait and Landscape on iPad/iPhone

You also want to add the maximum scale <meta name=”viewport” content=”width=device-width, initial-scale=1, maximum-scale=1″> UPDATED I agree with some of the comments, the declaration should not limit the scaling by the user as this is bad practice. The below is a better approach and I believe that the zooming bug has long since been fixed by … Read more

Android phone orientation overview including compass

You might want to check out the One Screen Turn Deserves Another article. It explains why you need the rotation matrix. In a nutshell, the phone’s sensors always use the same coordinate system, even when the device is rotated. In applications that are not locked to a single orientation, the screen coordinate system changes when … Read more

How to lock orientation of one view controller to portrait mode only in Swift

Things can get quite messy when you have a complicated view hierarchy, like having multiple navigation controllers and/or tab view controllers. This implementation puts it on the individual view controllers to set when they would like to lock orientations, instead of relying on the App Delegate to find them by iterating through subviews. Swift 3, … Read more

Flutter: How to set and lock screen orientation on-demand

First import the services package: import ‘package:flutter/services.dart’; This will give you access to the SystemChrome class, which “Controls specific aspects of the operating system’s graphical interface and how it interacts with the application.” When you load the Widget, do something like this: @override void initState(){ super.initState(); SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft, ]); } then when I leave … Read more

Detect viewport orientation, if orientation is Portrait display alert message advising user of instructions

if(window.innerHeight > window.innerWidth){ alert(“Please use Landscape!”); } jQuery Mobile has an event that handles the change of this property… if you want to warn if someone rotates later – orientationchange Also, after some googling, check out window.orientation (which is I believe measured in degrees…) EDIT: On mobile devices, if you open a keyboard then the … Read more

tech