ChenYilong / CYLTabBarController

[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item. [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar,支持中间带+号的TabBar样式,自带红点角标,支持动态刷新。【iOS13 & Dark Mode & iPhone XS MAX supported】
MIT License
6.92k stars 1.46k forks source link

cyl_showTabBadgePoint收到通知设置红点不显示,点击那个tabbaritem后才出现 #206

Closed iumiaomiao closed 6 years ago

iumiaomiao commented 6 years ago

Base Info for this issue

  1. Version:v1.13.1
  2. Language:Objective-C
  3. iOS System Version:iOS10
  4. Prototype(是否是真机):YES
  5. Issue Type:Crash、Bug、Enhancement(希望能支持一个新需求)、Q-A

1. How to repeat the problem.

2. Please help me in this way.

3. Here is a Demo.

4. Here is my Debug log

ChenYilong commented 6 years ago

贴下你设置的代码

iumiaomiao commented 6 years ago
- (void)onRCIMReceiveMessage:(RCMessage *)message left:(int)left {

    if (message.conversationType == ConversationType_CUSTOMERSERVICE) {
        UIViewController *viewController = [self cyl_tabBarController].viewControllers[3];
        [viewController cyl_showTabBadgePoint];
    }
    if (message.conversationType == ConversationType_GROUP) {
        UIViewController *viewController = [self cyl_tabBarController].viewControllers[1];
        [viewController cyl_showTabBadgePoint];

    }
}

你好,我收到融云过来的消息设置红点,发现不起作用,点击到那个tabbaritem后才显示

ChenYilong commented 6 years ago

fixed,请升级到v1.17.0或者以上版本。

ginhoor commented 6 years ago

这个问题仍然存在,我用的是v1.17.11,当tabbar不在显示区域的时候,使用cyl_showTabBadgePoint方法将无法显示小红点

ginhoor commented 6 years ago

曲线救国了 `[self.tabBarController setViewDidLayoutSubViewsBlock:^(CYLTabBarController *aTabBarController) {

    [aTabBarController.viewControllers[2] cyl_setTabBadgePointView:[UIView cyl_tabBadgePointViewWithClolor:[UIColor CEOrangeColor] radius:4.5]];

    if ([CEMessageManager sharedInstance].hasNewMessage) {
        [aTabBarController.viewControllers[2] cyl_showTabBadgePoint];
    } else {
        [aTabBarController.viewControllers[2] cyl_removeTabBadgePoint];
    }

    //添加提示动画,引导用户点击
    //        [_WeakSelf addScaleAnimationOnView:aTabBarController.viewControllers[3].cyl_tabButton.cyl_tabImageView repeatCount:20];
}];`
ChenYilong commented 5 years ago

v1.19.1 版本对小红点内部实现做了较大改动,已经能解决该问题了,请更新重试。

ChenYilong commented 5 years ago

另外APP启动后TabBar初始化显示出来,大都有懒加载,会有延迟,建议这样加红点:

    //添加小红点
    //添加提示动画,引导用户点击
    [[self cyl_tabBarController] setViewDidLayoutSubViewsBlockInvokeOnce:YES block:^(CYLTabBarController *tabBarController) {
        NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), @"");
        if ([self cyl_tabBarController].selectedIndex != 0) {
            return;
        }
        @try {
            UIViewController *viewControler0 = tabBarController.viewControllers[0];
            NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), viewControler0);
            [viewControler0 cyl_showBadge];
            [tabBarController.viewControllers[1] cyl_showBadgeValue:@"" animationType:CYLBadgeAnimTypeScale];
            [tabBarController.viewControllers[1] cyl_setBadgeBackgroundColor:[UIColor blueColor]];
            [tabBarController.viewControllers[2] cyl_showBadgeValue:@"test" animationType:CYLBadgeAnimTypeShake];
            [tabBarController.viewControllers[3] cyl_showBadgeValue:@"100" animationType:CYLBadgeAnimTypeBounce];
            [tabBarController.viewControllers[4] cyl_showBadgeValue:@"new" animationType:CYLBadgeAnimTypeBreathe];
        } @catch (NSException *exception) {}
    }];