【问题标题】:UITabbar UI issue in IOS 13 | XCode 11IOS 13中的UITabbar UI问题| X代码 11
【发布时间】:2020-09-23 15:24:52
【问题描述】:

当我在 XCode 11.1 中运行应用程序时,UITabbar 未选中的项目不可见,如图所示

    UITabBarController *tController=[[UITabBarController alloc] init];
    tController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"footerhover.png"];
    [tController.tabBar addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]];
    NSMutableArray *arr=[[NSMutableArray alloc] init];

    ProfileViewController *pViewController=[[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
    pViewController.tabBarItem.title=@"PROFILE";
    pViewController.tabBarItem.image=[UIImage imageNamed:@"profile_white.png"];
    pViewController.tabBarItem.tag = 1;
    if ([[[UIDevice currentDevice] systemVersion] compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending) {
    }else{

        [pViewController.tabBarItem setImage:[[UIImage imageNamed:@"profile.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [pViewController.tabBarItem setSelectedImage:[[UIImage imageNamed:@"profile_white.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

    }
    UINavigationController *nav1=[[UINavigationController alloc] initWithRootViewController:pViewController];
    senderArray[0] = nav1;
    [arr addObject:nav1];
    tController.viewControllers=senderArray;

Tabbar 在 XCode 10.3 / IOS 12 中运行良好。 请提出解决此问题的任何解决方案。

提前致谢

【问题讨论】:

  • [tController.view insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]] belowSubview:tController.tabBar]?这是真正的代码吗?这很可疑,因为您将字符串数组分配给 viewControllers 属性等。
  • @zrzka 编辑了我的代码。请检查一下。
  • 您是否尝试将底部栏图像视图移动到标签栏下方? (见第一条评论)
  • 是的。部分有效,你能把它作为答案....! @zrzka
  • 部分?所以有些东西仍然不适合你?

标签: ios objective-c uitabbarcontroller ios13 tabbar


【解决方案1】:

你必须替换这一行...

[tController.tabBar addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]];

...与...

[tController.view insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]
                   belowSubview:tController.tabBar];

addSubview 文档:

要添加的视图。添加后,此视图显示在任何其他子视图之上

【讨论】:

    猜你喜欢
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多