In Nativescript Angular, Is there anyway to detect orientation change and not allow content auto rotate but handling the content rotation manually? For example when rotating orientation from portrait to landscape, I want the content on the screen to stay still but i need to know that the screen is currently in landscape mode.
Im using nativescript-orientation plugin but this only allow me to disable the rotation. Once the rotation is disabled i could not detect the orientation change when the screen is landscape or portrait.
If you want to detect the orientation by yourself then you have to get the sensor data. I have never done this myself so I will just tell you where you can start. For IOS, you have get the sensor data from coremotion. You would require the data from the accelerometer and magnetometer sensors's data.
You can use the plugin nativescript-coremotion or You can directly access the IOS native methods yourself to do it.
Related
Scenario: I set the default device orientation to portrait. However, there are some Views that I want to allow for landscape mode.
Most of my views don't need to be in landscape. But there are some with orientation detection that allows a full-size linear graph to be displayed in landscape mode.
I want my application to behave as a Portrait-Centric for most of the time.
Question: How do I freeze the Portrait when I need to, but allow for Landscape when the situation warrants it?
You can manually allow, and most importantly in your case, disallow device orientation through UIInterfaceOrientation. Full description was already answered here: https://stackoverflow.com/a/40859280/13296047
I am writing an application that runs on Android TV 5.1 or newer that uses the WebView as the display rendering engine. I am able to set the desired display orientation, but the WebView rotates back to landscape within the display and maintains the correct aspect ratio.
I have tried using CSS to perform a transform but the aspect ratio is not correct. I have not found a method to force the WebView to rotate and fit the parent window.
Is there any method to set the orientation and size of the WebView itself? I see the same behavior on multiple devices.
This behavior is device specific. Some of the devices I have tested rotate as expected, another device rotates the display, but the WebView rotates back into landscape. The remaining devices I have tested do not rotate at all.
I will make this will be a known limitation of running this application on Android TV devices.
I have an iOS app that only supports portrait. When rotating the device the video captured by the RTCCameraVideoCapturer (WebRTC) rotates to landscape orientation, even when the rest of the UI stays in portrait. How to avoid this?
Do you have access to RTCCameraVideoCapturer codebases ? Also, I am not sure which version of the WebRTC codebases you are working with. And, in your application ; is landscape mode is the only mode that you are intending to support ?
There should be rotation calculation method that listen to rotation changes. You can just disabled it, or can use your preferred fixed set of rotation in spite of default.
For example, taking from this sample codebase ; you can just only use RTCVideoRotation_90 to have landscape orientation only.
So I have an app that needs to not use autorotate. Instead of rotating the screen the buttons on the screen are just supposed to rotate.
I have the interface locked in landscape left. How do I detect what rotation the buttons should be?
I am using a custom opengl engine so I can set the rotation of objects.
You can get the device orientation from:
UIDevice.orientation
This is not the interface orientation, so you get two more possible values for face up and face down. Also the landscape left and right are swapped compared to UIInterfaceOrientation.
You can listen for changes in device orientation by subscribing to the UIDeviceOrientationDidChange notification from NSNotificationCenter. You may have to enable these notifications by calling UIDevice.beginGeneratingDeviceOrientationNotifications().
If the interface orientation is locked on the device, it is not listening to any delegate methods related to orientation changes.
I can receive UIDeviceOrientationDidChangeNotification event, if auto-rotation is set.
But when screen auto rotation is disable, orientation notification doesn't work any more.
The effect I want to achieve is as iPhone Camera and Camera+: whatever the user lock or not lock the screen rotation, application can correspond to the rotation change immediately and correctly.
Does anyone has any idea why notification not sent when user lock the screen rotation?
How could I correspond to the device orientation change even if auto-rotation is disabled?
I also want to get the effect of the Camera app, where the app detects the orientation of the device even if the user has set Portrait Orientation Locked. UIDeviceOrientationDidChangeNotification is not posted when the user has portrait orientation locked. I believe the only way to determine the orientation of the device when the user has locked the orientation to portrait is to manually work out the orientation using UIAccelerometer.
The list of questions & answers below are all related to this issue. I found them when I was searching for an answer, and you might find them helpful too.
Related questions:
How to detect Camera Overlay view rotation
How to do Orientation Detection even the device has locked orientation
Detect iOS device orientation lock
Detect iPhone screen orientation
Callback method on auto rotation, iOS and iPad