In iOS5.1 and previous versions, we typically use shouldautorotatetointerfaceorientation: to individually control the spin-screen direction support for a uiviewcontroller, such as:
- -(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
- {
- return (interfaceorientation = = uiinterfaceorientationportrait);
- }
In iOS6, however, this method is deprecated and is not used.
Shouldautorotatetointerfaceorientation:
Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in IOS 6.0.) Override the supportedinterfaceorientations andpreferredinterfaceorientationforpresentation methods instead .)
In practice, it is found that the screen cannot be locked by a separate control via the supportedinterfaceorientations .
- -(Nsuinteger) supportedinterfaceorientations
- {
- return uiinterfaceorientationmaskportrait;
- }
After many experiments, the following methods are summarized to control the direction of the screen rotation support:
Subclass Uinavigationcontroller, adding methods
- -(BOOL) shouldautorotate
- {
- return self.topViewController.shouldAutorotate;
- }
- -(Nsuinteger) supportedinterfaceorientations
- {
- return self.topViewController.supportedInterfaceOrientations;
- }
and set it as the entry for the program, or designated as Self.window.rootViewController
Then add your own view controller, if you want to disable the spin screen of a View controller: (supports all versions of control)
- - (bool) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
- {
- return ( interfaceorientation == uiinterfaceorientationportrait);
- }
-   
- -(bool) shouldautorotate
- {  
- return no;
- }  
-
- -(Nsuinteger) supportedinterfaceorientations
- {
- < span class= "keyword" >return uiinterfaceorientationmaskportrait;
- }
If you want to turn on the full direction of a view controller, spin screen support:
- - (bool) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
- {
- return ( Interfaceorientation != uiinterfaceorientationportraitupsidedown);
- }
- &NBSP;&NBSP;
- -(Nsuinteger) supportedinterfaceorientations
- {&NBSP;&NBSP;
- return uiinterfaceorientationmaskallbutupsidedown;
- }&NBSP;&NBSP;
-
- -(bool) shouldautorotate
- {
- return yes;
- }
This allows for individual control of each view controller.
By the way, if all view controllers in the entire application do not support the spin screen, then simply:
- -(Nsuinteger) Application: (UIApplication *) application Supportedinterfaceorientationsforwindow: (UIWindow *) window
- {
- return uiinterfaceorientationmaskportrait;
- }
Next time, talk about IOS6 's memory control.
IOS6 control technique of rotary screen