IOS画面回転の検出と強制切替
3513 ワード
mark–画面の手動切り替え
mark–検出画面の切り替え
mark–制御画面の切り替えについて
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight]forKey:@"orientation"];
[[[self topViewController] class] attemptRotationToDeviceOrientation];
mark–検出画面の切り替え
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
//
/** */
- (void)orientChange:(NSNotification *)noti {
// NSDictionary* ntfDict = [noti userInfo];
UIDeviceOrientation orient = [UIDevice currentDevice].orientation;
switch (orient) {
case UIDeviceOrientationPortrait:
break;
case UIDeviceOrientationLandscapeLeft:
break;
case UIDeviceOrientationPortraitUpsideDown:
break;
case UIDeviceOrientationLandscapeRight:
break;
default:
break;
}
}
mark–制御画面の切り替えについて
/**
1 left 2 right 3 left andRight 4 up
*/
@property (nonatomic,assign) NSInteger rotatingNumer;
// appdelegate rotatingNumer
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
switch (self.rotatingNumer) {
case 1:
return UIInterfaceOrientationMaskLandscapeLeft;
break;
case 2:
return UIInterfaceOrientationMaskLandscapeRight;
break;
case 3:
return UIInterfaceOrientationMaskLandscapeLeft |UIInterfaceOrientationMaskLandscapeRight;
break;
case 4:
return UIInterfaceOrientationMaskPortrait;
break;
default:
return UIInterfaceOrientationMaskPortrait;
break;
}
}