方法: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 上刪除
}
}