In iOS5.1 and previous versions, we used shouldautorotatetointerfaceorientation: to individually control the direction of a Uiviewcontroller's spin-screen support, such as:
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
{return
( Interfaceorientation = = uiinterfaceorientationportrait);
}
In iOS6, however, this method is discarded 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 will be found that the screen cannot be locked by supportedinterfaceorientations alone control.
-(Nsuinteger) supportedinterfaceorientations
{return
uiinterfaceorientationmaskportrait;
}
After several experiments to summarize the control of screen rotation support direction of the following methods:
Sub-class Uinavigationcontroller, adding methods
-(BOOL) shouldautorotate
{return
self.topViewController.shouldAutorotate;
}
-(Nsuinteger) supportedinterfaceorientations
{
return self.topViewController.supportedInterfaceOrientations;
}
and set it as a program entry, or designate it as a Self.window.rootViewController
Then add your own view controller, if you want to disable the spin screen of a View controller: (Support for all versions of control)
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
{return
( Interfaceorientation = = uiinterfaceorientationportrait);
}
-(BOOL) shouldautorotate
{return
NO;
}
-(Nsuinteger) supportedinterfaceorientations
{return
uiinterfaceorientationmaskportrait;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/
If you want to turn on the full direction of a view controller, turn the screen support:
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
{return
( Interfaceorientation!= uiinterfaceorientationportraitupsidedown);
}
-(Nsuinteger) supportedinterfaceorientations
{return
uiinterfaceorientationmaskallbutupsidedown;
}
-(BOOL) shouldautorotate
{return
YES;
}
Thus, the individual control of each view controller is realized.
Incidentally, if all the view controller for the entire application does not support the spin screen, then simply:
-(Nsuinteger) Application: (UIApplication *) application Supportedinterfaceorientationsforwindow: (UIWindow *) window
{return
uiinterfaceorientationmaskportrait;
}
Next time, talk about IOS6 's memory control.