2012-01-23 73 views
1

我使用的XCode 4.2(故事板)無法旋轉只有一個視圖

我想僅旋轉視圖之一(不是所有的觀點),但它不不像是會工作...要麼不的觀點得到旋轉或全部

我都檢查摘要中的支持意見,並在信息,我確信,應用「支持的接口方向」都在那裏

在類這與視圖相關我編寫了旋轉此特定視圖的函數:

-(BOOL) shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation{ 
return(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown|| 
interfaceOrientation != UIInterfaceOrientationPortrait|| 
interfaceOrientation != UIInterfaceOrientationLandscapeRight|| 
interfaceOrientation != UIInterfaceOrientationLandscapeLeft) 
} 

當我旋轉屏幕時它仍然不旋轉......任何線索?

+0

你肯定那些「不平等「的經營者?你不應該使用「==」還是簡單地返回YES? – 2012-01-23 21:34:27

+0

我嘗試了「是」,並試圖== ...沒有工作 – user1051935

回答

2

你的方法可以簡化爲:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; { 
    return YES; 
} 

你想要做的是有設備支持的方向在所有你想要的方向的,然後在特定視圖的,使用上面的方法來允許您爲該視圖所需的方向。例如,如果您只想要特定視圖的橫向模式,您可以使用:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; { 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 

希望有助於!

1

shouldAutorotateToInterfaceOrientation你必須返回你想要支持的所有方向。

所以,如果你想你的應用程序的工作原理只是在肖像,這是該代碼使用方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

如果你想支持所有可能的方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
     return YES; 
    }