@property (nonatomic,assign) BOOL isPortraitIn_;
@property (nonatomic,assign) BOOL isSettingStatusBar_;
然后在.m文件里加上下面这段
//横屏显示
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation))
{
_isPortraitIn_ = YES;
self.view.transform = CGAffineTransformMakeRotation(M_PI_2);
if (orientation == UIInterfaceOrientationPortrait)
{
_isSettingStatusBar_ = YES;
[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
_isSettingStatusBar_ = NO;
}
else
{
_isSettingStatusBar_ = YES;
[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
_isSettingStatusBar_ = NO;
}
[self.view setFrame:CGRectMake(0, -10, self.view.frame.size.height+20,self.view.frame.size.width + 20)];
[self createCustomNavBar];
}
}