2011-01-08 72 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); 
    } 
} 
相关问题