我的导航控制器的导航栏时不会旋转为横向改变高度。 的UINavigationController的导航栏不会收缩时在横向模式
看到它停留在44个像素,而不是34,我认为。
我该怎么办,以解决这一问题?
我的导航控制器的导航栏时不会旋转为横向改变高度。 的UINavigationController的导航栏不会收缩时在横向模式
看到它停留在44个像素,而不是34,我认为。
我该怎么办,以解决这一问题?
您必须直接添加导航控制器作为一个子视图到你的窗口,否则这不自动工作。 (这是没有必要手动更改导航栏的框架。)
的-[application:didFinishLaunchingWithOptions:]
方法您AppDelegate
应该包含这样的
[window addSubview:self.yourNavController.view];
为了得到一个例子,其中该自动工作,你可以同样在Xcode中创建一个新的基于导航的应用程序,并添加实施,它总是返回YES的RootViewController的的shouldAutorotateToInterfaceOrientation:
方法。
在你的类的自转方法,改变你的导航栏像这样的框架:
- (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);
}
}
由于这是问题 – 2011-01-18 21:57:49