微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

RxTableViewSectionedAnimatableDataSource 不会在项目标识更改时调用 configureCell

如何解决RxTableViewSectionedAnimatableDataSource 不会在项目标识更改时调用 configureCell

同时更改空项目的身份(标识符 == nil)

extension Item: IdentifiableType {
    public var identity: Int64 {
        identifier ?? Self.emptyId
    }

    public static var emptyId: Int64 = .random(in: 0..<Int64.max)

    public static func refreshEmptyItemId() {
        Self.emptyId = .random(in: 0..<Int64.max)
    }
}

所以表视图不会刷新此项。为什么?

但是如果我这样做

extension Item: IdentifiableType {
    public var identity: Int64 {
        identifier ?? .random(in: 0..<Int64.max)
    }
}

然后它会刷新,但太频繁了,所以我更喜欢只在点击按钮时更改 ID。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。