1

移动到横向视图时,我面临一个隐藏 UITabBar 的问题。当我在 Xcode 4.6.1 和 iOS 6.1 模拟器中运行我的应用程序时,一切正常,但在 Xcode 5 和 iOS 7 模拟器中运行应用程序时,我面临以下问题。

我正在使用 tabBarController,3 个选项卡位于屏幕底部。其中一个选项卡具有从纵向视图切换到横向视图的功能。我们需要在纵向视图中显示 tabBars,但需要在横向视图中隐藏它们。将模拟器从纵向视图切换到横向视图时,tabBar 被隐藏,但我在底部看到一个空白区域。确认空白是由于 Tabbar 造成的,因为当我将 tabBar 的 hidden 属性更改为 NO

(self.tabBarController.tabBar.hidden = No;)

我可以在横向视图中看到空白区域较早出现的地方的 tabBars。

我正在共享 shouldAutorotateToInterfaceOrientation 的代码,我在其中创建横向视图。我尝试使用 [UIScreen mainScreen].bounds.size.width 而不是 self.tabBarController.view.bounds.size.width。我也尝试过硬编码宽度的值,但框架的宽度没有变化。

还有一件事要弄清楚,如果有人怀疑我们为什么要从超级视图中删除横向视图,使其为零,然后重新绘制它。这是必需的,因为我们的应用程序显示工作日 - 星期一、星期二、星期三,并且应用程序还支持更改为不同的语言。

因此,当用户选择不同的语言时,我们需要以相应的语言显示这些工作日标签,因此我们必须删除视图然后重新绘制它,因为 UILabes 不会自动刷新。

我已阅读有关此问题的一些帖子,但无法找出实际原因。如果有人有任何想法,请提出解决方案。

首先,我在 viewDidLoad() 中创建一个横向视图,如下所示 -

_landscapeView = [[MyWeekView alloc]initWithFrame:CGRectMake(0, 0, self.tabBarController.view.bounds.size.height, 320)];
[self.view addSubview:_landscapeView];

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    displayEmpName.frame = CGRectMake(0, 22.0, self.tabBarController.view.bounds.size.width, 34.0);
    _portraitView.hidden = YES;
    _landscapeView.hidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = YES;
    [[self.tabBarController.view.subviews objectAtIndex:0]setFrame:CGRectMake(0, 0, 480,320)];
    dayView.hidden = YES;

    [self.view bringSubviewToFront:_landscapeView];
    self.navigationItem.leftBarButtonItem = nil;


    //LABELS IN SCREEN  DO NOT CHANGE ON CHANGING LANGUAGE
    //RELOAD THE LANDSCAPE VIEW ONCE DEVICE IS CHANGED TO LANDSCAPE MODE

    [_landscapeView removeFromSuperview];
    _landscapeView = nil;
    _landscapeView = [[MyWeekView alloc]initWithFrame:CGRectMake(0, 0,  self.tabBarController.view.bounds.size.width, 320)];
    [self.view addSubview:_landscapeView];
    }
4

0 回答 0