我的導航控制器的導航欄時不會旋轉爲橫向改變高度。 的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