}
- ( NSUInteger )supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll ;
}
- ( UIInterfaceOrientation )preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait ;
//先恢复原状
self.view.transform = CGAffineTransformIdentity;
//隐藏导航栏
self.navigationController.navigationBarHidden = YES;
//隐藏状态栏
[UIApplication sharedApplication].statusBarHidden = YES;
//设置bounds
self.view.bounds = CGRectMake(0, 0, HDScreenWidth, HDScreenHeight);
//旋转view
[self.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
//设置状态栏方向,超级重要。(只有设置了这个方向,才能改变弹出键盘的方向)
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
私有API,设置设备方向。
//设置状态栏横屏
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
// [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:@(UIInterfaceOrientationLandscapeRight)];
}