旋转时隐藏导航栏

我有一个带导航栏的UIView。当用户将iPhone横向放置并在纵向视图上再次显示时,如何隐藏导航栏?     
已邀请:
这在文档中很容易找到。在UINavigationController文档中,要隐藏导航栏,请使用:
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated
如果要在设备旋转时执行此操作,则需要在视图控制器方法中执行此操作(在UIViewController文档中提到):
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [[self navigationController] setNavigationBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
    [[UIApplication sharedApplication] setStatusBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
}
    
恕我直言的更好方法是使用CGAffineTransform,并将导航栏留在原处 - 就像iPhone的照片库视图一样。请参阅Jeff Lamarche的精彩介绍Demystifying CGAffineTransform。帮助了我很多。     

要回复问题请先登录注册