Alert when orientation is changed - orientation

Im making my first app in xcode. I have set my supported interface orientation only to potrait. However, in one view I want to show an alert if the iphone is turned to the left (landscape left). Is there anyway to do that?

Related

Why does my display look different on iPhone simulator vs. iPad simulator?

I am working on a puzzle app on Xcode Version 11.0. My app displays as expected on my physical iPad mini and also on the iPhone simulators, but if I use an iPad simulator it appears to switch the orientation to Portrait mode and display my secondary screen as a popup on top of the secondary screen (see the images below).
I am using an "Action Segue" to get from my 1st screen to my 2nd screen. I have tried several different options (Show, Show Detail, Show Modally, Present As Popover). The result is slightly different, but all of them give the "Portrait popup" look. I am guessing that this is a newer feature, and I just need to set some flag to avoid it, but I don't have any guesses on what to look for. Could anyone offer some help?
iPhone 8 Simulator (this is what I want it to look like)
iPad Simulator (with undesired Portrait popup appearance)
Edit the segue to be Show Modally and also Fullscreen (instead of Automatic).

How do you launch an iOS app in the current device orientation?

I'm working with Xamarin and am having troubles launching my app in the current device orientation.
I have a UINavigationController that I set on my main UIWindow as the root controller. I created a custom UINavigationController which overrides the methods :
GetSupportedInterfaceOrientations
and
ViewWillTransitionToSize
If I hold my iPad in landscape mode and start the app, it will start in portrait mode and then rotate in landscape. I'd like to make it start in the same orientation as the device's physical orientation. From the doc I've read it seems that since iOS 8, everything related to rotations should be handled in the root uiview controller which is my custom UINavigationController.
And here's my problem... let's say I want to start my app in the current device's orientation and then block everything except Portrait once the app is loaded. I tried the 2 following solutions and none worked.
1- I put all interface orientations available in the supported interface orientations key in the info.plist file. I launched the app while holding the iPad in landscape mode. In this case, my app starts in the same orientation as the device which is cool. What is not cool is that it doesn't call my navigation controller method GetSupportedInterfaceOrientations anymore. So even if I change the return value of that method to Portrait only later one, it does absolutely nothing since the method is never called anymore.
2- I removed all supported interface orientations from the info.plist file. I lauched the app while holding the iPad in landscape mode. In this case, my app starts in portrait mode and then rotates to landscape. I want to prevent the rotation and just start the app in the current device's orientation (landscape). With this setup though, I can later change the supported orientation as the navigation controller method GetSupportedInterfaceOrientations is being called everytime we try to rotate the app.
In apple's doc, it says "At launch time, apps should always set up their interface in a portrait orientation. After the application (_:didFinishLaunchingWithOptions:) method returns, the app uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window."
The part where the view rotates to the appropriate orientation PRIOR to showing the window doesn't seem to work for me. It shows the window and then rotates it after.
So how do you launch an app in the current device's orientation (without the user seeing your first view rotate from portrait to whatever) and then be able to change the supported orientations later in the app? Example : I hold my iPad in landscape mode. I launch my app. First view I see is already in landscape mode. I can then rotate my iPad to change the view in portrait/landscape back and forth. Then I click a button which changes the supported orientation to Portrait which prevents me from changing the orientation to Landscape anymore.
Thanks!

Keep Screen From Turning to Landscape Mode While App Is Running - Swift

I created an app with Swift and tested it out on my iPod touch. The problem is, sometimes I accidentally rotate the screen a little while playing, which throws off everything entirely. Is there a way in Swift to make it so even if the player rotates the device sideways it never turns to landscape mode?
You will want to
Click on the top-left corner (Show the Project Navigator)
Select the name of your project
See what is under General->Deployment Info->Device Orientation.
Adjust the tickboxes accordingly.
Screenshot of Device Orientation in General settings
If you click on your project in top left corner and on the Info tab you can un-tick some of the orientation tick boxes to only allow Portrait.
It's simple.It's not on Swift though.Just swipe up on your ipod and a little tab should come up. Once there,a button with an unlocked lock with an arrow around it.Click it and it should become locked.Now,it won't turn into landscape mode when you turn it! :)

iOS: Change Orientation only for few pop-up views

I have an app which runs only in Landscape mode. All working well. But I have few pop-up views like Apptentative feedback view and Twitter Sheet view, works great when in portrait mode. So how can I change orientation forcefully when loading these pop-ups and back to landscape when these pop-up closes.
You can't force an orientation change. You can only support changes in orientation. IE moving the device 90 degrees to the right.

What is the usual/preferred landscape orientation for iOS apps?

Is it UIInterfaceLandscapeLeft (Home button on left) or UIInterfaceLandscapeRight (Home button on right)?
Note that the need is to support only one of them.
Old question!! Anyway...
As you can read here, you should find something like this in the documentation.
A landscape-only application should support both landscape
orientationsthat is, with the Home button on the right or on the
left. If the device is already physically in a landscape orientation,
a landscape-only application should launch in that orientation.
Otherwise, a landscape-only application should launch in the
orientation with the Home button on the right by default.
If so, UIInterfaceLandscapeRight should be prefered.

Resources