Our application starts in landscape mode ... in the plist Initial Interface Orientation is set to "Landscape (left home button)".
When debugging with the iPad simulator, after the application starts, we rotate the simulated iPad using either the menu option Hardware > Rotate Left or using the keyboard command-LeftArrow.
By placing a breakpoint in the View Controller at the entry point for didRotateFromInterfaceOrientation; we observe the breakpoint being hit when rotating into all positions except portrait-upside-down.
This happens if we rotate to the right as well. The breakpoint is hit when rotating into all positions except portrait-upside down.
Is this a known issue, or is there something required to activate this capability?
Thanks in advance.
After reading the post, duh.
shouldAutorotateToInterfaceOrientation does not explicitly assert UIInterfaceOrientationPortraitUpsideDown.
So yes, there is something required to activate this capability.
Hope this helps others in the future.
Related
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! :)
I am trying to make the multitasking switcher open in landscape mode all the time... even when the phone is being held in portrait... Any ideas? The class is "SBAppSwitcherController" and I'm calling the method "viewDidAppear"
Just set the Supported Interface Orientations to only landscape modes. To do that, you go to your project in the Project Navigator. Then, you will see the Supported Interface Orientations header. Click the dark icons referring to portrait mode to make them light. Then your program will only be in landscape mode. So, if I know what you are saying, you are done!
I am writing an app and run into two problems. I have been searching the web all night without success and wonder if anyone here can help.
When the application starts, I want it to default to Landscape mode and Detect whether it is in UIInterfaceOrientationLandscapeLeft or UIInterfaceOrientationLandscapeRight. I have created the UI in landscape mode in the .xib file. However, when I check self.interfaceOrientation it always returns UIInterfaceOrientationLandscapeLeft regardless of whether the home button is on the left or right in the iPad simulator.
When the user rotates the iPad between the two landscape orientation, I want the view the change. To illustrate with a simplified example, if it is UIInterfaceOrientationLandscapeLeft, I want to write 1 on the left side of the screen and 2 on the right side of the screen. In UIInterfaceOrientationLandscapeRight, write 2 on the left side of the screen and 1 on the right side of the screen. Which method in iOS can tell me whenever the user rotates the device?
Thanks very much in advance.
Joe
Where are you checking that? If you're doing it in applicationDidFinishLaunching or in the view controller's viewDidLoad then it's likely the interface orientation isn't set properly yet. Wait until viewWillAppear or viewDidAppear to check that.
Take a look at shouldAutorotateToInterfaceOrientation in your view controller. You need to return YES to supported orientations so in your case you want to return YES if interfaceOrientation is landscape (there's a helper function for checking landscape vs portrait by the way). Also look at didRotateFromInterfaceOrientation which tells you when the user has rotated.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
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.
I appreciate I'm probably missing something basic here, but...
My iPad app will only support landscape mode, and has a MainWindow.xib Window that I'd like to work on in landscape mode in XCode 4, however the pull-down menu to change this (Simulated Metrics -> Orientation) is always grayed out.
I notice that Views can be rotated just fine, it's only Windows that can't be rotated in XCode 4 using this setting.
Is there a workaround for this, or do I have to put a View on top of the MainWindow in order to rotate it?
I think it's because apps always starts up in portrait and then rotates to appropriate oriantations. From the UIViewController docs:
Note: At launch time, applications should always set up their
interface in a portrait orientation. After the
application:didFinishLaunchingWithOptions: method returns, the
application uses the view controller rotation mechanism described
above to rotate the views to the appropriate orientation prior to
showing the window.
So you'll need the UIViewController magic for the simulated metrics to make any sense. If you used the "Window-based application" template as a starting point for your project try the "View-based application" template instead.