在appdelegate.h 加上
在appdelegate.m加上
需要转横屏的viewcontroller.m #import "AppDelegate.h" 初始化时这样就行了:
@property(nonatomic,assign)NSInteger allowRotation;
在appdelegate.m加上
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (_allowRotation == 1) {
return UIInterfaceOrientationMaskLandscapeRight;
}
else
{
return (UIInterfaceOrientationMaskPortrait);
}
}
需要转横屏的viewcontroller.m #import "AppDelegate.h" 初始化时这样就行了:
AppDelegate appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 1;
返回时要
appDelegate.allowRotation = 0;