The Wayback Machine - https://web.archive.org/web/20200919123427/https://github.com/tigerAndBull/TABAnimated/pull/97
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for iOS 14 #97

Closed
wants to merge 1 commit into from
Closed

update for iOS 14 #97

wants to merge 1 commit into from

Conversation

@laurivers
Copy link

laurivers commented Jul 24, 2020

iOS 14 UITableViewCell 的 subviews 有了较大变化

  • iOS 13 中 TableViewCell 的 subviews

[UITableViewContentView, 自己添加的其他控件]

  • iOS 14 中 TableViewCell 的 subviews

[_UISystemBackgroundView, 自己添加的其他控件, UITableViewContentView]

结果是在 iOS 14 上会跳过 _UISystemBackgroundView, 但是把 UITableViewContentView 也画出骨架来.

因为 iOS 14 还未正式发布, 这里目前基于 beta 3 做了简单的 workaround. 直接判断如果是 _UISystemBackgroundView 这个类就直接跳过, 不确定是否影响上架, 需要后续跟进

@laurivers laurivers mentioned this pull request Jul 24, 2020
2 of 2 tasks complete
@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

为什么是subView.count-1?
这个地方代码是否是有效的,我没有14的设备。

if (@available(iOS 14, *)) {
  if (i == (subViews.count - 1)) {
          continue;
   }
} 
@laurivers
Copy link
Author

laurivers commented Sep 2, 2020

为什么是subView.count-1?
这个地方代码是否是有效的,我没有14的设备。

if (@available(iOS 14, *)) {
  if (i == (subViews.count - 1)) {
          continue;
   }
} 

我在上面列举了 iOS 13 和 iOS 14 上 subviews 的数组格式

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

不好意思,看到了,这个视图结构怎么这么奇怪。
等14正式版出来第一时间更新,目前先观望一下。
我们自己的过滤操作是不影响上架的,你放心。

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

或者你提供一下层级截图,提前更新上去吧

@mrtian2016
Copy link

mrtian2016 commented Sep 2, 2020

模拟器可以复现这个问题,我有同样的问题 但是 复制laurivers 的代码并没有解决 我在laurivers的代码前加了一句

    UIView *subV = subViews[i];
    if (subV.tabAnimated) continue;
    if (@available(iOS 14, *)) {
        //            NSLog(@"%@", NSStringFromClass(subV.class));
        if([NSStringFromClass(subV.class) isEqualToString:@"UITableViewCellContentView"]) {
            
            continue;
            
        }
        if (([subV.superview isKindOfClass:[UITableViewCell class]] ||
             [subV.superview isKindOfClass:[UICollectionViewCell class]] ||
             [subV.superview isKindOfClass:[UITableViewHeaderFooterView class]]) &&
            [NSStringFromClass(subV.class) isEqualToString:@"_UISystemBackgroundView"]) {
            // 此处排除cell中的_UISystemBackgroundView, _UISystemBackgroundView 的 subviews 不为空
            if (i == 0) {
                continue;
            }
        }
    }
    [self _recurseProductLayerWithView:subV array:array isCard:isCard];
@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

你们俩提供一下视图层级截图给我,我处理一下,这个问题在iOS正式版发布之前更新。
@laurivers @mrtian2016

@mrtian2016
Copy link

mrtian2016 commented Sep 2, 2020

image

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

给我看到数组即可,不要可视化。

@mrtian2016
Copy link

mrtian2016 commented Sep 2, 2020

image

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

了解了,就说contentView并不固定存在subViews的最后一个,但是systemBackgroundView一定是第一个。

@mrtian2016
Copy link

mrtian2016 commented Sep 2, 2020

contentView应该是最后一个 因为cell上的按钮无效 需要contentView.isUserInteractionEnabled = false

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

这两个视图不打算采用Index过滤,根据class类型过滤比较安全。

@laurivers
Copy link
Author

laurivers commented Sep 2, 2020

这两个视图不打算采用Index过滤,根据class类型过滤比较安全。

现在我是用的 _UISystemBackgroundView 类型来过滤的,但是不确定会不会影响上架。

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 2, 2020

这两个视图不打算采用Index过滤,根据class类型过滤比较安全。

现在我是用的 _UISystemBackgroundView 类型来过滤的,但是不确定会不会影响上架。

不会,这个不影响。

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 4, 2020

@laurivers 更改为class类型过滤,测试好重新pull给我,这个由你来负责完善吧,麻烦啦~

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 4, 2020

@mrtian2016 老哥,麻烦同步下这个case的最新进展,目前我的机器有点限制,没有14.0的环境。

@mrtian2016
Copy link

mrtian2016 commented Sep 5, 2020

for (int i = 0; i < subViews.count;i++) {

    UIView *subV = subViews[i];
    if (subV.tabAnimated) continue;
    if (@available(iOS 14, *)) {
        if ([NSStringFromClass(subV.class) isEqualToString:@"UITableViewCellContentView"] ||
            [NSStringFromClass(subV.class) isEqualToString:@"_UISystemBackgroundView"]) {
                continue;
        }
    }
    [self _recurseProductLayerWithView:subV array:array isCard:isCard];
    
    // 移除UITableView/UICollectionView的滚动条
    if ([view isKindOfClass:[UIScrollView class]]) {
        if (((subV.frame.size.height < 3.) || (subV.frame.size.width < 3.)) &&
            subV.alpha == 0.) {
            continue;
        }
    }
    
    // 标记移除:会生成动画对象,但是会被设置为移除状态
    BOOL needRemove = [self _isNeedRemove:subV];
    // 生产
    TABComponentLayer *layer;
    if ([TABAnimatedProductHelper canProduct:subV]) {
        UIColor *animatedColor = [_controlView.tabAnimated getCurrentAnimatedColorWithCollection:_controlView.traitCollection];
        layer = [self _createLayerWithView:subV needRemove:needRemove color:animatedColor isCard:isCard];
        layer.serializationImpl = _controlView.tabAnimated.serializationImpl;
        layer.tagIndex = self->_targetTagIndex;
        [array addObject:layer];
        _targetTagIndex++;
    }
}

目前我是这样过滤的

@laurivers
Copy link
Author

laurivers commented Sep 5, 2020

模拟器可以复现这个问题,我有同样的问题 但是 复制laurivers 的代码并没有解决 我在laurivers的代码前加了一句

    UIView *subV = subViews[i];
    if (subV.tabAnimated) continue;
    if (@available(iOS 14, *)) {
        //            NSLog(@"%@", NSStringFromClass(subV.class));
        if([NSStringFromClass(subV.class) isEqualToString:@"UITableViewCellContentView"]) {
            
            continue;
            
        }
        if (([subV.superview isKindOfClass:[UITableViewCell class]] ||
             [subV.superview isKindOfClass:[UICollectionViewCell class]] ||
             [subV.superview isKindOfClass:[UITableViewHeaderFooterView class]]) &&
            [NSStringFromClass(subV.class) isEqualToString:@"_UISystemBackgroundView"]) {
            // 此处排除cell中的_UISystemBackgroundView, _UISystemBackgroundView 的 subviews 不为空
            if (i == 0) {
                continue;
            }
        }
    }
    [self _recurseProductLayerWithView:subV array:array isCard:isCard];

for (int i = 0; i < subViews.count;i++) {

    UIView *subV = subViews[i];
    if (subV.tabAnimated) continue;
    if (@available(iOS 14, *)) {
        if ([NSStringFromClass(subV.class) isEqualToString:@"UITableViewCellContentView"] ||
            [NSStringFromClass(subV.class) isEqualToString:@"_UISystemBackgroundView"]) {
                continue;
        }
    }
    [self _recurseProductLayerWithView:subV array:array isCard:isCard];
    
    // 移除UITableView/UICollectionView的滚动条
    if ([view isKindOfClass:[UIScrollView class]]) {
        if (((subV.frame.size.height < 3.) || (subV.frame.size.width < 3.)) &&
            subV.alpha == 0.) {
            continue;
        }
    }
    
    // 标记移除:会生成动画对象,但是会被设置为移除状态
    BOOL needRemove = [self _isNeedRemove:subV];
    // 生产
    TABComponentLayer *layer;
    if ([TABAnimatedProductHelper canProduct:subV]) {
        UIColor *animatedColor = [_controlView.tabAnimated getCurrentAnimatedColorWithCollection:_controlView.traitCollection];
        layer = [self _createLayerWithView:subV needRemove:needRemove color:animatedColor isCard:isCard];
        layer.serializationImpl = _controlView.tabAnimated.serializationImpl;
        layer.tagIndex = self->_targetTagIndex;
        [array addObject:layer];
        _targetTagIndex++;
    }
}

目前我是这样过滤的

要不麻烦你更新到你的 fork 上 然后提 pr

@mrtian2016
Copy link

mrtian2016 commented Sep 5, 2020

提了 你看一下

@songxing10000
Copy link

songxing10000 commented Sep 18, 2020

image
app应用内自有黑白模式,在黑色模式下cell居然变白了
我目前有效果的代码
image

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 18, 2020

image
app应用内自有黑白模式,在黑色模式下cell居然变白了
我目前有效果的代码
image

app内自己的黑白模式,要手动设置darkModeType

@tigerAndBull
Copy link
Owner

tigerAndBull commented Sep 19, 2020

2.4.7已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.