Form: http://wenxin2009.iteye.com/blog/1681584
Ios5 rotating screen: (The following is the Health Check Code, and there are instances in the attachment)
The portrait and landscape screens are two different viewcontrollers. Two viewcontrollers must be created during implementation.
// Screen Rotation
-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation {
If (tointerfaceorientation = uiinterfaceorientationlandscapeleft | tointerfaceorientation = uiinterfaceorientationlandscaperight ){
// Scenario jump Method 1
[Self authentication mseguewithidentifier: @ "landscapeid" Sender: Self];
// Scenario jump Method 2 (programming)
// Uistoryboard * mainstoryboard = [uistoryboard storyboardwithname: @ "mainstoryboard" Bundle: Nil];
// Landscapeviewcontroller * Land = [mainstoryboard instantiateviewcontrollerwithidentifier: @ "mylandscape"];
// Land. modaltransitionstyle = uimodaltransitionstylecoververtical;
// [Self presentviewcontroller: Land animated: Yes completion: Nil];
Return yes;
} Else if (tointerfaceorientation = uiinterfaceorientationportrait ){
Return yes;
} Else {
Return no;
}
}
// Test the rotation method.
- // When the rotation direction changes
- -(Void) willanimaterotationtointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation duration :( nstimeinterval) Duration {
- }
- // Automatically called before the first half of the view rotation animation occurs
- -(Void) willanimatefirsthalfofrotationtointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation duration :( nstimeinterval) Duration {
- }
- // Automatically called before the last half of the view rotation animation occurs
- -(Void) willanimatesecondhalfofrotationfrominterfaceorientation :( uiinterfaceorientation) frominterfaceorientation duration :( nstimeinterval) Duration {
- }
- // Automatically called before view Rotation
- -(Void) willrotatetointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation duration :( nstimeinterval) Duration {
- }
- // Automatically called after view Rotation
- -(Void) didrotatefrominterfaceorientation :( uiinterfaceorientation) frominterfaceorientation {
- }
- // Automatically calls the first half of a view rotation animation after it occurs.
- -(Void) didanimatefirsthalfofrotationtointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation {
- }
Ios6 is so neat:
# Ifdef _ iphone_6_0
-(Bool) shouldautorotate {
Return no;
}
-(Nsuinteger) supportedinterfaceorientations {
Return
Uiinterfaceorientationmaskportrait;
}
# Endif
The following plist settings support orientation rotation: