2009-12-05 72 views
1

我在應用程序中有MainWindow.xib。Iphone +主窗口+方向問題

在界面生成器中,我將主窗口從縱向旋轉到橫向,而不是將很少的UIControls放在它上面。

比我省得它。

之後,當我運行應用程序,雖然在設計時我做了一切在橫向模式,它總是以縱向模式顯示的東西。

請幫我

回答

2

IB只是設置你的XIB文件。這是您的視圖控制器管理方向。

默認的UIViewController或UINavigation控制器有關於此的詳細信息。

具體來說,您需要重載

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES); 
} 

看一看的UIViewController中的文件以獲得更多信息。

4

除了重寫shouldAutorotate以說明您支持的方向之外,還應該在您的info.plist文件中設置「初始界面方向」鍵以設置您的首選初始方向。

有關更多信息,請搜索iPhone Application Programming Guide中的「在風景模式下啓動」。

+0

該主題現在位於技術說明TN2244:在Landscape中啓動應用程序,位於http://developer.apple.com/library/ios/#technotes/tn2244/_index.html – 2011-11-02 17:16:59