而不是使用setNavigationBarHidden:animated:
隱藏導航欄,試試這個:
在您的視圖控制器的viewDidLoad
計算不同的幀爲您導航欄和您的看法:
// The normal navigation bar frame, i.e. fully visible
normalNavBarFrame = self.navigationController.navigationBar.frame;
// The frame of the hidden navigation bar (moved up by its height)
hiddenNavBarFrame = normalNavBarFrame;
hiddenNavBarFrame.origin.y -= CGRectGetHeight(normalNavBarFrame);
// The frame of your view as specified in the nib file
normalViewFrame = self.view.frame;
// The frame of your view moved up by the height of the navigation bar
// and increased in height by the same amount
fullViewFrame = normalViewFrame;
fullViewFrame.origin.y -= CGRectGetHeight(normalNavBarFrame);
fullViewFrame.size.height += CGRectGetHeight(normalNavBarFrame);
當你想要去的全屏:
[UIView animateWithDuration:0.3
animations:^{
self.navigationController.navigationBar.frame = hiddenNavBarFrame;
self.view.frame = fullViewFrame;
} completion:^(BOOL finished) {
}];
當你想恢復到正常:
[UIView animateWithDuration:0.3
animations:^{
self.navigationController.navigationBar.frame = normalNavBarFrame;
self.view.frame = normalViewFrame;
} completion:^(BOOL finished) {
}];
在iOS 5.1仿真器中進行了測試。希望你能使用它。 「黑色矩形」必須是窗口的默認背景顏色,即導航欄和視圖之間的間隙。
你有沒有找到解決這個問題的解決方案? –
@nessup nope,還沒有。 – Francesco