2011-01-08 78 views

回答

5

您必須直接添加導航控制器作爲一個子視圖到你的窗口,否則這不自動工作。 (這是沒有必要手動更改導航欄的框架。)

-[application:didFinishLaunchingWithOptions:]方法您AppDelegate應該包含這樣的

[window addSubview:self.yourNavController.view]; 


爲了得到一個例子,其中該自動工作,你可以同樣在Xcode中創建一個新的基於導航的應用程序,並添加實施,它總是返回YES的RootViewController的的shouldAutorotateToInterfaceOrientation:方法。

+0

由於這是問題 – 2011-01-18 21:57:49

-1

在你的類的自轉方法,改變你的導航欄像這樣的框架:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)) 
    { 
     self.navigationController.navigationBar.frame = CGRectMake(0,0,480,32); 
    } 
    else if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) 
    { 
     self.navigationController.navigationBar.frame = CGRectMake(0,0,320,44); 
    } 
    else 
    { 
     assert(false); 
    } 
} 
相關問題