AppDelegate.h中
@property(nonatomic,assign)NSInteger allowRotation;
AppDelegate.m中
初始化allowRotation
self.allowRotation = 0;
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (_allowRotation == 1) {
return UIInterfaceOrientationMaskAllButUpsideDown;//这个可以根据自己的需求设置旋转方向
}
else
{
return (UIInterfaceOrientationMaskPortrait);
}
}
这样设置之后,在想要支持横竖屏切换的界面设置
#import "AppDelegate.h"
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = 1;
这样就可以实现旋转了
网友评论