Questions tagged [device-orientation]

Use device-orientation for questions related to coding for both landscape and portrait modes of a device which can be rotated by the user

References


511 questions
245
votes
32 answers

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

I am building a website specifically for mobile devices. There is one page in particular which is best viewed in landscape mode. Is there a way to detect if the user visiting that page is viewing it in Portrait mode and if so, display a message…
Dan
  • 10,171
  • 7
  • 38
  • 31
173
votes
14 answers

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

On one of my flutter pages, I need the screen to set to landscape mode and lock it so it can't rotate into portrait mode, but only on the one page. So need a way to enable this function on-the-fly. Anyone know how to do this? I would like it to…
Jus10
  • 14,519
  • 21
  • 52
  • 77
143
votes
17 answers

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

Since my app got support for all orientation. I would like to lock only portrait mode to specific UIViewController. e.g. assume it was Tabbed Application and when SignIn View appear modally, I only want that SignIn View to the portrait mode only no…
Thiha Aung
  • 5,036
  • 8
  • 36
  • 79
122
votes
4 answers

Force “landscape” orientation mode

I'm trying to force the "landscape" mode for my application because my application is absolutely not designed for the "portrait" mode. How can I do that?
user1599537
  • 1,269
  • 3
  • 10
  • 10
109
votes
4 answers

Android phone orientation overview including compass

I've been trying to get my head around the Android orientation sensors for a while. I thought I understood it. Then I realised I didn't. Now I think (hope) I have a better feeling for it again but I am still not 100%. I will try and explain my…
Tim
  • 5,767
  • 9
  • 45
  • 60
51
votes
7 answers

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

I've built a responsive site using Twitter Bootstrap here: http://zarin.me/cce/ The responsive design works great on iPad and iPhone, however when I flip the device from portrait to landscape, the site is zoomed in instead of adapting to the screen…
37
votes
7 answers

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

if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) { print("landscape") } if UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation){ print("portrait") } How can I check if it's…
mafioso
  • 1,630
  • 4
  • 25
  • 45
31
votes
5 answers

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

This question is about iOS device rotation and multiple controlled views in a UINavigationController. Some views should be constrained to portrait orientation, and some should autorotate freely. If you try and create the simplest setup with three…
31
votes
5 answers

how to change video orientation in MediaRecorder to portrait

When I record video by MediaRecorder, it always records in landscape mode, regardless of real device orientation. How to force MediaRecorder/Camera use real orientation ?
28
votes
2 answers

The simplest way to solve gimbal lock when using DeviceOrientation events in javascript - How to make a perfect spirit level/bubble level app

Starting with... window.addEventListener("deviceorientation", handleDeviceTilt); function handleDeviceTilt(event){ // Here we can use event.beta, event.gamma // Note that we don't need event.alpha because that's just the compass as we // don't need…
28
votes
10 answers

How to get current orientation of device programmatically in iOS 6?

I have developed an iOS App and tested it on iOS6 device. While testing, I realized that my App is not responding to Orientation changes as expected. Here is my Code: // Autorotation (iOS >= 6.0) - (BOOL) shouldAutorotate { return NO; } -…
Code Hunter
  • 10,075
  • 23
  • 72
  • 102
21
votes
8 answers

UIScreen applicationFrame returning incorrect rectangle on landscape application launch (iPhone/iPad)

Having trouble getting the correct bounds for my iPad application when launching it in landscape mode. I have the proper keys set in my Info.plist file, and my view controllers launch properly in landscape (and portrait, natch). In my…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
19
votes
3 answers

iOS: Disable Autorotation for a Subview

I have a nested view hierarchy for an iPad application that supports orientation changes. It looks similiar to the following. UIViewController UIView - UIView - UIImageView (disable rotation) - UIImageView …
Jason George
  • 6,992
  • 8
  • 44
  • 60
19
votes
9 answers

Fragment gets initialized twice when reloading activity with tabs when orientation changes

I have a problem reloading an activity with tabs and fragments when I change the orientation of my device. Here's the situation: I have an activity which has 3 tabs in the action bar. Each tab loads a different fragment in a FrameLayout in main…
Gerardo Contijoch
  • 2,421
  • 5
  • 20
  • 29
18
votes
9 answers

How do I detect orientation on app launch for splash screen animation on iPad!

Hi I have an app and I have two *.pngs for default splash screen: Default-Landscape.png Default-Portrait.png What I want is to animate this default splash screen away when my app is loaded and ready to go. To achieve this I would normally present…
1
2 3
34 35