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) {
}];
iOS5.1エミュレーターでこれをテストしました。あなたがそれを使うことができることを願っています。「黒い長方形」は、ウィンドウのデフォルトの背景色、つまりナビゲーションバーとビューの間のギャップである必要があります。