此方法适用于 IOS 6 和旧版本
-(BOOL)rotationChanged:(UIInterfaceOrientation)interfaceOrientation {
NSInteger 方向 = [[UIDevice currentDevice] 方向];
UIWindow *_window = [[[UIApplication sharedApplication] delegate] window];
if ([PGPlatformUtils GetCurrentPlatform]==PGPlatformEnum_iPhone) {
开关(方向){
情况1:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (0)];
[_window setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait 动画:YES];
[UIView 提交动画];
休息;
案例2:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (M_PI)];
[_window setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait 动画:YES];
[UIView 提交动画];
休息;
案例3:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (M_PI / 2)];
[_window setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight 动画:YES];
[UIView 提交动画];
休息;
案例4:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (- M_PI / 2)];
[_window setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft 动画:YES];
[UIView 提交动画];
休息;
案例5:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (0)];
[_window setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIPrintInfoOrientationLandscape 动画:YES];
[UIView 提交动画];
休息;
默认:
休息;
}
}
别的{
开关(方向){
情况1:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (0)];
[_window setFrame:CGRectMake(0, 0, 768, 1024)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait 动画:YES];
NSLog(@"*** 1 定向调用 0");
[UIView 提交动画];
休息;
案例2:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (M_PI)];
[_window setFrame:CGRectMake(0, 0, 768, 1024)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown 动画:YES];
NSLog(@"*** 1 定向调用 M_PI");
[UIView 提交动画];
休息;
案例3:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (M_PI / 2)];
[_window setFrame:CGRectMake(0, 0, 768, 1024)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight 动画:YES];
NSLog(@"*** 1 次定向调用 M_PI/2");
[UIView 提交动画];
休息;
案例4:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (- M_PI / 2)];
[_window setFrame:CGRectMake(0, 0, 768, 1024)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft 动画:YES];
NSLog(@"*** 1 定向调用 - M_PI/2");
[UIView 提交动画];
休息;
案例5:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
[_window setTransform:CGAffineTransformMakeRotation (0)];
[_window setFrame:CGRectMake(0, 0, 768, 1024)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIPrintInfoOrientationLandscape 动画:YES];
NSLog(@"*** 1 定向调用 0");
[UIView 提交动画];
休息;
默认:
休息;
}
}
返回是;
}