Flipboard / FLAnimatedImage

Performant animated GIF engine for iOS
MIT License
7.93k stars 1.22k forks source link

When I use gifs in the tableView, it has no animation after sliding. #223

Open HolyLe opened 5 years ago

HolyLe commented 5 years ago

I commented out this code and it returned to normal.

- (void)purgeFrameCacheIfNeeded
{
//     Purge frames that are currently cached but don't need to be.
//     But not if we're still under the number of frames to cache.
//     This way, if all frames are allowed to be cached (the common case), we can skip all the `NSIndexSet` math below.
    if ([self.cachedFrameIndexes count] > self.frameCacheSizeCurrent) {
        NSMutableIndexSet *indexesToPurge = [self.cachedFrameIndexes mutableCopy];
        [indexesToPurge removeIndexes:[self frameIndexesToCache]];
        [indexesToPurge enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
            // Iterate through contiguous indexes; can be faster than `enumerateIndexesInRange:options:usingBlock:`.
            for (NSUInteger i = range.location; i < NSMaxRange(range); i++) {
                [self.cachedFrameIndexes removeIndex:i];
                [self.cachedFramesForIndexes removeObjectForKey:@(i)];
                // Note: Don't `CGImageSourceRemoveCacheAtIndex` on the image source for frames that we don't want cached any longer to maintain O(1) time access.
#if defined(DEBUG) && DEBUG
                if ([self.debug_delegate respondsToSelector:@selector(debug_animatedImage:didUpdateCachedFrames:)]) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [self.debug_delegate debug_animatedImage:self didUpdateCachedFrames:self.cachedFrameIndexes];
                    });
                }
#endif
            }
        }];
        NSLog(@"%@\n   %@\n   %@\n", self.cachedFrameIndexes, indexesToPurge,[self frameIndexesToCache]);
    }
}