How to refresh UICollectionViewCell in iOS 7?

后端 未结 3 1500
半阙折子戏
半阙折子戏 2021-02-04 15:04

I am trying to develop my app in Xcode 5 and debug it under iOS 7 environment.

I have a customized UICollectionViewLayoutAttributes.

I plan to do something after

3条回答
  •  余生分开走
    2021-02-04 15:38

    In iOS 7, you must override isEqual: in your UICollectionViewLayoutAttributes subclass to compare any custom properties that you have.

    The default implementation of isEqual: does not compare your custom properties and thus always returns YES, which means that -applyLayoutAttributes: is never called.

    Try this:

    - (BOOL)isEqual:(id)other {
        if (other == self) {
                return YES;
        }
        if (!other || ![[other class] isEqual:[self class]]) {
                return NO;
        }
        if ([((MyUICollectionViewLayoutAttributes *) other) isActived] != [self isActived]) {
            return NO;
        }
    
        return YES;
    }
    

提交回复
热议问题