2012-01-25 58 views
1

我在xcode中有storyboard項目。大多數場景以縱向顯示,但我希望以橫向模式顯示其中一個場景,而無需用戶旋轉設備,總是顯示此場景必須處於橫向。這個場景有一個uiwebview對象的簡單視圖控制器,我從url打開一個pdf文件。我的想法是將視圖控制器顯示爲模式視圖控制器。如何在xcode storyboard中以橫向模式顯示場景?

任何人都知道如何解決這個問題?,昨天我花了我的時間在互聯網上搜索這個,但我沒有找到一個解決方案。

預先感謝您!

回答

3

場景如何實際顯示不是由故事板而是由視圖控制器決定的。只有在界面方向爲橫向時,您才需要創建UIViewController子類並實施- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation以返回YES。你可以做這樣的:

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

允許兩個方向或

return interfaceOrientation == UIInterfaceOrientationLandscapeLeft 

更換,只允許一個方向。

+0

謝謝...我添加了代碼,我改變了uiwebview的尺寸,完美!,工作正常!... – Camacho

相關問題