2012-12-14 34 views
0

我想在我的應用程序中消除風景方向,該應用程序是爲IOS 5構建的。在IOS 6中,我知道這是可能的 - 但在早期版本中似乎不適用於我。在iOS5中禁用風景定位

我只在我的plist文件中設置了兩個方向(縱向帶有主頁按鈕的縱向和縱向帶有主頁按鈕的縱向)。無論如何,景觀仍然在IOS 5中崛起。

我還需要做些什麼來消除這種情況?

回答

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    // return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
{ 
    return NO; 
} 
else 
{ 
    return YES; 
} 

} 

寫這段代碼.m文件爲iOS5的方向

讓我知道這是工作或不....

編碼愉快!!!!

+0

它沒有工作。 – venkat

0

這將工作。轉到故事板取消選擇你不想要的方向,並在視圖控制器中寫下如下代碼:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation==UIInterfaceOrientationPortrait); 
} 
+0

它在IOS中不工作。我可以如何禁用風景方向?可以幫助我。感謝不滿意 – venkat