2014-02-27 82 views
0

我只想在横向模式下制作屏幕。对ios5来说工作很好。但在iOS 7中,它不起作用。我使用以下代码在ios7中提供支持。ios7不支持横向方向

-(BOOL)shouldAutorotate{return TRUE;} 
-(NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskLandscape;} 

它不会接到所有屏幕的呼叫。 谢谢。 AKS。

+0

系统会要求root viewController获取方向信息。确保你的代码在rootVC – Jing

+0

我写了这个代码在视图controller.m。它第一次接到电话。但在导航到下一个屏幕后没有打电话。 – AKS

+0

您使用UINavigationController从A移动到B?如果是这样,你应该继承UINavigationController,并在那里写代码。您在A中编写的代码将不起作用 – Jing

回答

0
- (BOOL)shouldAutorotate 
{ 
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

    if (orientation==UIDeviceOrientationLandscapeRight || orientation==UIDeviceOrientationLandscapeLeft) { 

     return YES; 
    } 
    return NO; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 
+0

但问题是,当导航到下一个屏幕时,它没有接到呼叫。 – AKS

+0

从您的根控制器中,调用viewController中的shouldAutorotate。如果您使用导航控制器,则可以使用[self.navigationcontroller topViewController]显示控制器。在rootViewController的shouldAutorotate中写入“[topviewcontroller shouldAutorotate];” –