2014-02-26 50 views
0

我正在开发应用程序并在Xcode 5上开发。应用程序适用于从iOS 5到iOS 7的iPad支持。我将应用限制在左侧和右侧,这是在plist和项目设置中定义的。 此外,通过代码 在应用程序委托在Xcode 5中限制iOS 5横版的自动旋转

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
return UIInterfaceOrientationMaskLandscape; 
} 

定义在类

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 
- (NSUInteger)supportedInterfaceOrientations{ 
return UIInterfaceOrientationMaskLandscape; 
} 

但是发生了什么事,它工作正常,在iOS 7和iOS 6,但它总是旋转到iOS 5时设备移动肖像。我卡在这里如何限制这只在景观。请帮助我。提前致谢。

回答

0

U可锁定方向更改。

- (BOOL)shouldAutorotate 
    { 
     if (autoRotate) { 
     return YES; 
     } 
     else 
     { 
     return NO; 
     } 
    } 
+0

不适用于iOS 5 ... – iPatel

+0

是...在6.0之后弃用它。 – KethanKumar

+0

抱歉没有工作!!!! :( – josh

0

尝试用下面的代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
     return YES; 
    else 
     return NO; 
} 

通过使用上面的代码的设备没有与纵向旋转。

+0

谢谢@iPatel,我实现了这个方法,它不是调用循环,而是调用控制器加载一次。 – josh

+0

@josh - 我在我的项目中使用上面的代码它为我工作: ) – iPatel

+0

难道你不这么认为,这可能是设备的问题。因为我做了所有事情,并且它在其他设备上工作得很好?你的经验说的是,这可能吗? – josh