问题
If a Single View app is created for iPad, depending on the Supported Device Orientation is set for the plist, and what shouldAutorotateToInterfaceOrientation
returns, shouldAutorotateToInterfaceOrientation
can be called 10, 12, or even 13 times.
One simple case is, if the "Support Device Orientation" is set to Landscape Left, and shouldAutorotateToInterfaceOrientation
also returns YES
only for Landscape Left, then if I start the app in Landscape Left orientation, then shouldAutorotateToInterfaceOrientation
will be called 12 times in a row. If I hold it in other orientation and start the app, then it is 13 times.
What is the reason that it is called so many times in a row?
回答1:
As i can see at UIDevice.h, orientation type is not used as a mask and several requests should be performed:
- check whether the current orientation is supported
- if not, find the supported orientation with 1-3 or 1-4 requests
The whole process could happen more than one time for a single orientation change (e.g. the system might want to send the correct notification to the application window the status bar might want to check the orientation independently, welcome to OOP, i'm not saying it happens, but it might) while the results of the 1st or 2nd stages might be somehow cached by one component and not by another.
来源:https://stackoverflow.com/questions/10768524/on-ios-why-is-shouldautorotatetointerfaceorientation-called-10-12-or-13-times