我有一个带有导航栏的UIView。当用户将iPhone横向放置时,我该如何隐藏导航栏,并在纵向视图中再次显示它?
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[[self navigationController] setNavigationBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
}
在文档中很容易找到。在UINavigationController文档中,要隐藏导航栏,您可以使用:
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration