我有一台带导航栏的UIView。当用户将iPhone置于横向时,如何隐藏导航栏,并使其在纵向视图中重新显示?
发布于 2009-01-12 19:10:43
这在文档中很容易找到。在UINavigationController文档中,要隐藏导航栏,您可以使用:
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated如果要在设备旋转时执行此操作,则需要在视图控制器方法中执行此操作(在UIViewController文档中提到):
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration发布于 2010-02-27 21:15:09
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[[self navigationController] setNavigationBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
}发布于 2009-01-13 21:17:24
一个更好的方式是使用CGAffineTransform,把导航栏留在原处--就像iPhone的相册视图一样。请参阅Jeff Lamarche的优秀介绍Demystifying CGAffineTransform。这对我有很大帮助。
https://stackoverflow.com/questions/436413
复制相似问题