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

[en]bug appears when use cyl_showTabBadgePoint and cyl_popSelectTabBarChildViewControllerAtIndex at same time [cn]设置红点之后在原tabbar 上出现黑条 #298

Closed yFeii closed 5 years ago

yFeii commented 6 years ago

Base Info for this issue

在tabbar=2的列表push->详情。在详情页调 cyl_popSelectTabBarChildViewControllerAtIndex 时出现黑条

  1. Version:pod 'CYLTabBarController', '~> 1.17.4'
  2. Language:Objective-C
  3. iOS System Version:iOS11
  4. Prototype(是否是真机):YES
  5. Issue Type:Bug、

1. How to repeat the problem.

在tabbar=2的列表push->详情。在详情页调 cyl_popSelectTabBarChildViewControllerAtIndex 时出现黑条 图在这 https://i.loli.net/2018/09/05/5b8f61e63eff7.png

yFeii commented 6 years ago
if ([hasRedTip boolValue]) {

        CYLTabBarController *tabbarC = RootTabBarController;
        UIViewController *vc = tabbarC.viewControllers[2];
        vc.tabBarItem.badgeValue = @" ";
//        UIView *tabBadgePointView1 = [UIView cyl_tabBadgePointViewWithClolor:UIColorHexMake(@"#FF0937") radius:4.5];
//        @try {
//            [tabbarC.viewControllers[2] cyl_setTabBadgePointView:tabBadgePointView1];
//            [tabbarC.viewControllers[2] cyl_showTabBadgePoint];
//
//        } @catch (NSException *exception) {}
    }

使用系统badge 则不会出现

ChenYilong commented 5 years ago

我复现了: emassuite02 应该是设置小红点的方法导致的问题。 目前推测原因是: 调用 cyl_popSelectTabBarChildViewControllerAtIndex 后,会执行会执行 setSelectedIndex 和 popToRootViewControllerAnimated:NO,还有小红点导致的布局更新, 导致动画卡顿。

比如我像下面这样实现cyl_popSelectTabBarChildViewControllerAtIndex方法,就可避免黑条出现,但是 随着delaySeconds的减少,可能出现tabbar消失的问题。 且popToRootViewControllerAnimated:YES,动画属性必须是YES。

- (UIViewController *)cyl_popSelectTabBarChildViewControllerAtIndex:(NSUInteger)index  {
    UIViewController *viewController = [self cyl_getViewControllerInsteadOfNavigationController];
    [viewController checkTabBarChildControllerValidityAtIndex:index];
    NSUInteger delaySeconds = 0.8;
    CYLTabBarController *tabBarController = [self cyl_tabBarController];
        [self.navigationController popToRootViewControllerAnimated:YES];
    dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
    dispatch_after(when, dispatch_get_main_queue(), ^{
            tabBarController.selectedIndex = index;
    });
    UIViewController *selectedTabBarChildViewController = tabBarController.selectedViewController;
    UIViewController *fromViewController = [selectedTabBarChildViewController cyl_getViewControllerInsteadOfNavigationController];
    return fromViewController; 
}

故小红点实现内部有问题,所以目前建议不同时使用标题里我提到的两个API方法。后期我打算更新下小红点的实现,现在的实现方法,引入了较多bug。

ChenYilong commented 5 years ago

v1.19.0更改小红点实现方式,解决了该问题,并增加多个API自定义红点UI样式、动画效果。请更新重试。

yFeii commented 5 years ago

好的