横屏模式下隐藏选项卡栏

4
我正在开发一款使用选项卡栏(tab bar)的应用程序(iphone app)。
其中一个视图是相机视图,用户可以拍照。是否有一种方法在用户切换到横屏模式时隐藏位于屏幕底部的标签栏(tab bar)?然后在切换到纵向模式时,标签栏可以重新出现?
提前感谢。
2个回答

4

使用UIViewController的代理方法:- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

每次方向改变时都会调用它。然后,一个简单的if语句应该检查并决定何时设置标签栏隐藏,像这样:

伪代码:

if (toInterfaceOrientation  == landscape)
   [[self tabbarcontroller]tabbar sethidden:YES];
else
   [[self tabbarcontroller]tabbar sethidden:NO];

1
if (toInterfaceOrientation  == landscape)
   self.tabBarController.tabBar.hidden = YES;
else
   self.tabBarController.tabBar.hidden = NO;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接