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.91k stars 1.45k forks source link

与 Log in 状态结合决定选中后 Lottie 动画是否执行的问题 #378

Closed meilbn closed 5 years ago

meilbn commented 5 years ago


Base Info for this issue

  1. Version:1.25.0
  2. Language of App :Objective-C
  3. iOS System Version:iOS12
  4. Prototype(是否是真机):YES,模拟器也一样
  5. Issue Type:Q-A

1. How to reproduce the problem.

在可以延迟登录的 App 里面,点击某些操作,或者,像点击底部 TabBar 中的“我的”的时候,要求用户登录,这样的话,UITabBarControllerDelegate- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController 方法会判断是否已登录,没有登录的话,就会弹出登录界面,这个方法返回 NO,但是如下图所以,Lottie 动画还是会执行,但是标签页并没有选中“我的”。

Screenshot 2019-05-29 at 19 26 15

2. Please help me in this way.

如果 - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController 方法返回 NO,Lottie 动画并不执行。

3. Here is a Demo.

Demo 已发至邮箱。

4. Here is my Debug log


ChenYilong commented 5 years ago

收到,今天发布版本修复下。

meilbn commented 5 years ago

感谢,我现在也在尝试修改源码,但是出现别的问题。再试试自己项目里面修改下是否能避免。期待新版本。

微博@iOS程序犭袁 notifications@github.com 于2019年5月29日周三 下午8:34写道:

收到,今天发布版本修复下。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChenYilong/CYLTabBarController/issues/378?email_source=notifications&email_token=AAZW24YYEN7UVHHLAU3CQULPXZZ7FA5CNFSM4HQL3FTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWPFWXA#issuecomment-496917340, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZW242KJHD5IQHF4K7NRXTPXZZ7FANCNFSM4HQL3FTA .

ChenYilong commented 5 years ago

无需修改源码,我看了下你的demo,你的写法有问题,添加如下的代码既可,Lottie也考虑到的该场景,已经尝试可以满足你的需求。

#pragma mark - UITabBarControllerDelegate

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    BOOL should = ![((CYLBaseNavigationController *)viewController).topViewController isKindOfClass:[MineViewController class]];
//缺少了下面这一行的代码,如下代码用来同步是否选中的状态。
    [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController shouldSelect:should];
    return should;
}

TabBarDemo-fixed.zip

参考:https://github.com/ChenYilong/CYLTabBarController/issues/259

meilbn commented 5 years ago

感谢,看来是我没仔细看头文件,这样写的确可以的。👍

微博@iOS程序犭袁 notifications@github.com 于2019年5月30日周四 上午3:53写道:

我看了下你的demo,你的写法有问题,添加如下的代码既可,Lottie也考虑到的该场景,已经尝试可以满足你的需求。

pragma mark - UITabBarControllerDelegate

  • (BOOL)tabBarController:(UITabBarController )tabBarController shouldSelectViewController:(UIViewController )viewController {

    BOOL should = ![((CYLBaseNavigationController *)viewController).topViewController isKindOfClass:[MineViewController class]]; //缺少了下面这一行的代码,如下代码用来同步是否选中的状态。

    [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController shouldSelect:should];

    return should;

}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChenYilong/CYLTabBarController/issues/378?email_source=notifications&email_token=AAZW24ZIBBAR2MBDVCPIUFLPX3NLNA5CNFSM4HQL3FTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWQOWAQ#issuecomment-497085186, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZW24447HA6YXT664GFRSTPX3NLNANCNFSM4HQL3FTA .

meilbn commented 5 years ago

现在发现一个新的问题,字典中都设置了 CYLTabBarLottieSize(如 24),但是第一个 tabBarItem 的 lottie 图片大小还是 22,第二个大小是指定的。

ChenYilong commented 5 years ago

我用你的demo试了试,40大小,都可以设置成功。你看下:

+ (NSArray<NSDictionary *> *)tabBarItemsAttributesForController {
    return @[@{
                CYLTabBarItemTitle : @"Discover",
                CYLTabBarLottieURL : [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"discover" ofType:@"json"]],
                CYLTabBarLottieSize : [NSValue valueWithCGSize:CGSizeMake(40, 40)],
                },
             @{
                CYLTabBarItemTitle : @"Mine",
                CYLTabBarLottieURL : [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"mine" ofType:@"json"]],
                CYLTabBarLottieSize : [NSValue valueWithCGSize:CGSizeMake(40, 40)],
                }];
}

meilbn commented 5 years ago

真奇怪,公司项目里面第一个就是没成功的,Demo 里面是可以的。 抱歉,我自己再看看,不是库的问题。。。

ChenYilong commented 5 years ago