2016-05-26 29 views
0

嗨,我是使用下面的景观模式的代码只有一个视图控制器如何在横向模式下显示一个视图控制器?

- (BOOL)shouldAutorotate { 
return NO; 
} 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
return UIInterfaceOrientationLandscapeRight; // or Right of course 
} 

- (UIInterfaceOrientationMask)supportedInterfaceOrientations { 
return UIInterfaceOrientationMaskLandscape; 
} 

它工作正常,但是当我旋转为纵向然后旋转,我使用下面的代码用于呈现视图

[self presentViewController:vc animated:YES completion:nil]; 

在那里我提前缺少感谢

+0

同样的问题昨天 –

+0

问我可以知道你的应用是否为纵向或横向使你的ViewController?@Bittoo – Madhu

+0

@Madhu两个但在景观 – Bittoo

回答

0

使用此代码

在你AppDelegate.h

@property (assign, nonatomic) BOOL shouldRotate; 

AppDelegate.m 

BOOL shouldRotate; 
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 
      if (self.shouldRotate) 
       return UIInterfaceOrientationMaskAllButUpsideDown; 
      else 
       return UIInterfaceOrientationMaskPortrait; 
    } 

目前打开要应用的方向和使用此代码

AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; 
[appDelegate setShouldRotate:YES]; // set NO to disable rotation 
+0

一个视图控制器我试着按你说的,但它是旋转potrait模式也 – Bittoo

相关问题