方法:1app
-(BOOL)shouldAutorotate{ide
return YES;server
}it
- (NSUInteger)supportedInterfaceOrientationsio
{object
return UIInterfaceOrientationMaskAll;select
}方法
注意该方法要写在控制器的根视图里才生效notification
2.通知: (要想在哪一个页面都实现这种方法写在 APPdelegate 里)view
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
- (void)statusBarOrientationChange:(NSNotification *)notification{ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
//在这个位置建立 view 或者 VC
if (orientation == UIInterfaceOrientationLandscapeRight) // home键靠右
{
//将 vc 或者 view 加到 window 上
}
if (orientation ==UIInterfaceOrientationLandscapeLeft) // home键靠左
{
//将 vc 或者 view 加到 window 上
}
if (orientation == UIInterfaceOrientationPortrait)
{
//将 vc 或者 view 从 window 上删除
}
if (orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//将 vc 或者 view 从 window 上删除
}
}