2
votes

I'm working on a photo capturing application.

My app only supports portrait mode and I have to rotate landscape images to rotate them for the portrait mode. For example I want to rotate the photo 90 degrees right if it was captured in landscapeRight.

But if user device is in "Lock screen orientation" mode, I can't get the correct device orientation value with UIDevice.current.orientation if user is trying to take a landscape positioned photo. It always returns "portrait" value of course due to the "lock screen oritentation".

I want to ask permission to user for unlocking screen orientation with like "This application wants to unlock your screen orientation" message. Is it possible to add my info.plist to add a permission request for unlocking screen orientation? And if yes, which permission do I have to add in my info.plist?

Thanks in advance.

1
I'm missing something, maybe an important detail. I have two image-processing apps, both all orientations. Early this year I discovered that just about any small developer image app works in portrait only. (Yeah, it made my day.) My point is this - none of these apps ask for permission. My take is that as a project property they set things to be portrait only. (I also have a few games like this - portrait only.) Screen locks don't matter, right? So why do you wish to ask permission?dfd
@dfd Because users may take landscape photos while in camera mode in my app. Logically my app works only portrait mode of course but when user rotates the device to landscape, user feels that the camera is taking landscape (but camera is still in portrait mode). My question is in that point. I want to rotate the taken photo automatically before showing it to user. But I can't reach device's orientation mode (lanscapeRight or landscapeLeft) if device in lock screen orientation mode. So I want to the user should unlock the device's orientation lock.kkakkurt

1 Answers

1
votes

I concur you can't change the orientation properties. All those properties (in your project page) do is to enable state variables and notifications from which you can animate the orientation of your UI. So perhaps a hacky solution would be to look at using gyroscope APIs, and to make a small algorithm based on that to detect device rotation. It would essentially come down to building logic similar to a Leveling App. https://developer.apple.com/documentation/coremotion/cmmotionmanager