典型的NavController行爲是在端口/橫向時調整大小。從44px高度到32px我相信(從我的頭頂上)。將UINavigationB自動調整爲橫向旋轉
我正在使用故事板並將導航欄包含在VC中,而不是控制器中。在縱向和橫向之間旋轉時,導航欄不會自動調整大小。
我看到這個答案,但是這並不能幫助:Resizing UINavigationBar on rotation
導航欄是通過外觀控制器,它是在App代表加載:
UIImage *portraitImage = [UIImage imageNamed:@"mainNavBar"];
UIImage *landscapeImage = [UIImage imageNamed:@"mainNavBarLandscape"];
[[UINavigationBar appearance] setBackgroundImage:portraitImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:landscapeImage forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,nil]];
[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin];
不幸的是,最後沒有什麼區別和因爲導航欄將包含在多個控制器中,所以我不想在上面的問題答案中重複相同的粘合代碼,以便我的所有VC在旋轉時調整大小。
正確,我也注意到,發佈後不久。謝謝 – StuartM 2013-04-30 17:31:55