Swift How to get orientation when orientation is locked - swift

the orientation in the app is locked. However, on the news detail page, I need to start the video full screen while in landscape. How can I find out the landscape status?

Related

Trying to achieve YouTube-like full-screen video handling with Flutter

I'm trying to achieve something similar to this post, but here I'm also gonna talk about my attempt.
In short, I just wanna achieve the same full-screen functionality as YouTube.
When the user tapped on the full-screen icon, the video becomes full screen in landscape and it stays like that even though the user keeps holding the device vertically. The video will be automatically minimized if the device is rotated to portrait after the device had been rotated to landscape.
If the user does not lock the device rotation, the video will be put in full screen when the device is tilted to landscape and will be minimized when tilted back to portrait.
If the video is being played on full screen, tapping the full-screen icon will minimize the video and also put the app orientation to portrait regardless of the way user holds the device.
Here is my attempt at achieving the above behaviors with Flutter:
App's preferred orientation is not set (allows both landscape and portrait)
Watch for orientation change. Programmatically put the video on full screen if the current orientation is landscape and minimize the video in portrait.
Set the app's preferred orientation to landscape when the full-screen icon is tapped. (The video will be on full screen)
To allow users to physically rotate the device back to portrait set preferred orientations to both portrait and landscape after 1 second.
// Tapped on full-screen icon
SystemChrome.setPreferredOrientations(
<DeviceOrientation>[
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
],
);
await Future.delayed(
const Duration(milliseconds: 1000),
);
// Allow rotating physically back to portrait
SystemChrome.setPreferredOrientations(
<DeviceOrientation>[
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp,
],
);
The code above works as expected on an iOS device as iPhone does not immediately change its orientation back to portrait when the preferred orientation is set back to both landscape and portrait while the device is being held vertically.
The problem here is with Android devices.
After 1 second, if the device is still being held vertically, the app orientation will change to portrait which is not the desired behavior.
Is there any practical way to achieve my desired behaviors? I strongly believe that what I have done is not even close to how YouTube does it.

iAd content always displayed in portrait using landscape only app

My current app is landscape only.
I display an iAd banner in bottom area of screen. It's showing correctly in landscape mode.
However tapping it, the ad content screen is sliding in from the right when holding landscape right and from the left when holding landscape left. The ad content screen is always displayed in portrait mode. Is there no way to display ad content screen in landscape mode?
Using iOS 6+.
This is similar but seems to deal with acceleration etc. My app does not rotate except between the two landscape modes. (and actually it seems that that topic is about the banner itself, not the opening ad content screen)
Landscape iAd is showing the portrait graphic in iOS6?
Edit: Apple's iAdSuite seems to do the same. The apps support portrait modes too, but in landscape mode, tapping on an landscape ad the opening ad content is in landscape mode.
http://developer.apple.com/library/ios/samplecode/iAdSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010198
It looks like this is by design(?) hmmm... not pretty
I can't confirm it but it just seems that there is no landscape ad content.

Orientation issue in webview

I am opening an url in my universal application in a web view with orientation enabled, in portrait orientation first time the website load properly but when I change the orientation from portrait to landscape its working properly but when come back from landscape to portrait the website's contents of bottom dose not load, its working properly in iPod's, and iPhone both orientation properly but only iPad portrait orientation the bottom content dose not load when I change orientation, and when I open this url in my iPad safari browser all things working properly, please help me someone.
Thanks in Advance,
Rameshu

How to detect portrait lock (orientation lock) in an app that records video?

I have an app which records video. I only supported landscape at first, but now I'm offering portrait and other orientations. I set the transform of the video to the orientation it was filmed in as detected from UIDevice. However, with portrait lock on the phone, UIDevice would tell me the current orientation is portrait even if the user was holding the device in landscape.
How can I determine if it's locked, so I can save the video in the proper orientation?
Use the accelerometer on the device to detect orientation.
Check this link for more info:
Detect iPhone screen orientation

UIDEVICE orientation

hello all i have my splash screen which i want to show in landscape mode and all other screen in potrait mode. My root view controller is acting as a splash screen i am writing this code in viewdidload method
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
But this code is not working and shows me that UIdevice may not respond to setorentation please guide me that how could i change the orentation for only first splash screen and also other screen should be in potrait mode
UIDeviceOrientation refers to the physical orientation of the device whereas UIInterfaceOrientation refers to the orientation of the user interface. You can't change the physical orientation of the device, but you can change how the status bar is displayed via [UIApplication sharedApplication].statusBarOrientation
Can't you just have a splash screen that is displayed sideways?
The user will interpret that as a "landscape" splash and adjust accordingly, whether or not your application actually thinks it is. Just make sure to return NO in shouldAutorotateToInterfaceOrientation: so it doesn't rotate away when the user turns it.
But a warning: it's probably worthwhile to tweak your splash screen so it is in the portrait orientation, since it may be annoying to suggest to the user that your app likes landscape, and then switch to portrait as soon as it actually starts.
If you really want to, though, you can use setStatusBarOrientation:animated: on the UIApplication to force the orientation.