shouldAutorotateToInterfaceOrientation called several times in a row without any rotation


I am trying to implement some interface changes in my app, based on the device rotation.

My app is a view based app. So, its main view controller has a didload method.

The app starts in portrait. Almost all changes on the device orientation triggers the shouldAutorotateToInterfaceOrientation method but this method is not called when the device is put on portrait, after coming from any landscape orientation.

While debugging the app, I have put a

NSLog(@"orientation=%d", interfaceOrientation);

on my shouldAutorotateToInterfaceOrientation method, and what I see is quite strange:

<ul><li>When I run the app, shouldAutorotateToInterfaceOrientation is called 6 times before the app's interface even appears. Every time it runs, it reports a different number for the orientation: the order it reports on console is: portrait, portrait, portrait, landscape right, landscape left, upside down) (????).</li> </ul>

During this time the app is just beginning. The debugger reports all 6 calls coming from the app's delegate.

So, here comes the questions:

<ol><li>WHy shouldAutorotateToInterfaceOrientation is not being called when the device enters on portrait?</li> <li>Why is the delegate calling this method 6 times before the app's is even visible, specially when no rotation is being done?</li> </ol>



The <a href="http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html" rel="nofollow">UIViewController Class Reference</a> seems to say that this method returns a value "indicating whether the view controller supports the specified orientation".

It doesn't make any promises that the device is/isn't rotating right now, it's just querying to see what orientations your controller can support. Hence the statement:


Your view controller is either capable of supporting a given orientation or it is not.



The system is caching the responses so it knows what orientations to try and detect.


  • device rotated but screen not stretches
  • Autolayout and Constraints for iPad
  • Disable rotation for one UITabbar item
  • iPad Orientations
  • Distribute images evenly to columns in gallery
  • UIActionSheet orientation
  • How can I rotate a UIViewController to its supported interface orientation when navigating to it?
  • How to get phone heading for augmented reality?
  • Why won't my UITableViewCell deselect and update its text?
  • CFNetwork SSLHandshake failed (-9806) & (-9800) & (-9830)
  • How would I send and receive packets over a WebSocket in Javascript
  • removing the default blue color on focus
  • ggplot2 polygon world map centred with limits gives funny edges
  • HTTP Module intercept requests and breaks custom errors configuration
  • Update varbinary(MAX) field in SQLServer 2012 Lost Last 4 bits
  • Spring integration inbound-gateway Fire an event when queue is empty
  • What causes the runtime difference in this trivial fortran code?
  • Is there a package like bigmemory in R that can deal with large list objects?
  • netsh acl setting (need alternative method - registry settings?)
  • Debugging VB6 Code From Visual Studio 2010
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • ViewController With Transparent Background Entering Current ViewController With Push Transition
  • Saving Changes After In-App Purchase Has Been Purchased
  • QLPreviewController hide print button in ios6
  • debug library loaded with ctypes using gdb
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Java: can you cast Class into a specific interface?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • AES padding and writing the ciphertext to a disk file
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Perl system calls when running as another user using sudo
  • Why winpcap requires both .lib and .dll to run?
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android