gpt4 book ai didi

iphone - 标签栏项目上的角标(Badge)未显示

转载 作者:行者123 更新时间:2023-12-01 17:59:56 24 4
gpt4 key购买 nike

在我的应用程序中,我的 tabBar 项的标记值设置在 AppDelegate.m ,如下:

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
[[tabBarController.tabBar.items objectAtIndex:4] setBadgeValue:@"1"];
...
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
[[tabBarController.tabBar.items objectAtIndex:4] setBadgeValue:@"2"];
...
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
[[tabBarController.tabBar.items objectAtIndex:4] setBadgeValue:@"3"];
...
}

问题是:角标(Badge)值始终为“1”。为什么在 applicationWillEnterForeground: 中都设置了角标(Badge)值和 applicationDidBecomeActive:永远不会出现?如果我没有在 application: didFinishLaunchingWithOptions: 中设置角标(Badge)值,那里没有显示角标(Badge)。

最佳答案

您需要阅读 UIApplicationDelegate 协议(protocol)以及各种状态转换。 applicationDidBecomeActive 转换不会在启动时发生,只有在手机中发生一组状态更改时才会发生。

关于iphone - 标签栏项目上的角标(Badge)未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11628950/

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