2014-02-26 45 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