为什么我的UITabBar在纵向加载时向下移动20个像素?
我正在UINavigationController
加载UITabBarController
。 默认情况下, UITabBar
的UITabBarController
将它放在视图的底部。 通过使用默认选项,在横向启动应用程序时,该栏将在底部正确显示。
这也使肖像正确显示在底部,(但只有当横向模式启动应用程序)。
如果我以纵向方式启动应用程序,则会在两个横向上向下移动状态栏的高度:
和肖像:
我正在尝试与CNBC应用程序产生类似的效果,并在视图顶部显示UITabBar
。 在回顾了Mihai Damian的问题之后,我试图自定义UITabBar。
我只是简单地添加了几行代码:
-(void)loadView{ UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; contentView.backgroundColor = [UIColor clearColor]; self.view = contentView; [contentView release]; orderingTabBarController = [[UITabBarController alloc] init]; OrderingSpecialsViewController *specialsViewController = [[OrderingSpecialsViewController alloc] initWithNibName:@"OrderingSpecialsViewController" bundle:nil]; OrderingProductViewTabBarController *productViewTabBarController = [[OrderingProductViewTabBarController alloc] init]; OrderingSummaryViewController *summaryViewController = [[OrderingSummaryViewController alloc] init]; specialsViewController.title = @"SPECIALS"; productViewTabBarController.title = @"PRODUCT"; summaryViewController.title = @"ORDER SUMMARY"; [orderingTabBarController setViewControllers:[NSArray arrayWithObjects:specialsViewController, productViewTabBarController, summaryViewController, nil] animated:YES]; orderingTabBarController.tabBar.frame = CGRectMake(0.0, 110.0, self.view.frame.size.width, 40.0); [specialsViewController release]; [productViewTabBarController release]; [summaryViewController release]; [self.view addSubview:orderingTabBarController.view]; }
当我尝试修改UITabBar的框架时,它将在横向模式下消失:
当人物以横向和纵向再次开始时,分别出现在纵向的不同高度上。
以横向模式启动:
以纵向模式启动:
有没有人遇到过这个问题? 如果是的话,你是怎么解决的呢? 任何帮助在这里将不胜感激。
它似乎只是在纵向模式下加载状态栏的20个像素,就好像它没有find状态栏,即使它在那里,因此它在已经存在的20个像素的顶部增加了20个像素为状态栏。
我实际上是通过IB来解决的。 由于某种原因,视图控制器想要添加一个状态栏,所有你需要做的就是在IB上设置最大值,然后检查resize视图以适合。 另外,请确保您的视图的尺寸设置为768 x 1024。