#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (_allowRotation == 1) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}else{
return (UIInterfaceOrientationMaskPortrait);
}
}
// 支持设备自动旋转
- (BOOL)shouldAutorotate
{
if (_allowRotation == 1) {
return YES;
}
return NO;
}
/**
iOS如何指定某个页面可以旋转屏幕,其余控制器都正常竖屏?
在你要旋转的controller中一开始的地方写这两句就可以了
**/
- (void)setupView{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 1;
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 0;
}