gpt4 book ai didi

cocoa-touch - 为什么我的 UITabBar 在纵向加载时向下移动 20 像素?

转载 作者:行者123 更新时间:2023-11-29 11:23:51 24 4
gpt4 key购买 nike

我正在 UINavigationController 中加载 UITabBarController。默认情况下,UITabBarControllerUITabBar 将其放置在 View 的底部。通过使用默认选项,当应用在横向上启动时,栏会正确显示在底部位置。

enter image description here

这也使纵向显示在底部正确,(但仅当应用程序以横向模式启动时)。 enter image description here

如果我以纵向启动应用程序,它似乎会向下移动两个横向状态栏的高度: enter image description here

和肖像: enter image description here

我正在尝试获得与 CNBC 应用程序类似的效果,并在 View 顶部显示 UITabBar。审核后Mihai Damian's question我尝试自定义 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 的框架时,它在横向模式下消失了: enter image description here

并且分别在横向和纵向启动时出现在纵向上的不同高度。

以横向模式启动: enter image description here

以纵向模式启动: enter image description here

有没有人遇到过这个问题?如果是这样,您是如何解决的?此处的任何帮助将不胜感激。

它似乎只是在纵向模式下加载 View 时添加了状态栏的 20 像素,就好像它没有找到状态栏,即使它在那里,因此,它在已经存在的基础上添加了 20 像素状态栏现有 20 像素。

最佳答案

我实际上通过 IB 解决了这个问题。由于某种原因, View Controller 想要添加一个状态栏,您所要做的就是在 IB 上将其设置为无,并检查调整 View 大小以适合。此外,请确保将 View 的尺寸设置为 768 x 1024。

关于cocoa-touch - 为什么我的 UITabBar 在纵向加载时向下移动 20 像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4997253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com