的緩存性能試試這個!使用__weak爲你的在AFTNetworking
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 // 10MB. memory cache
diskCapacity:100 * 1024 * 1024 // 50MB. on disk cache
diskPath:nil];
sessionConfiguration.URLCache = cache;
sessionConfiguration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
在的CollectionView:cellForItemAtIndexPath:
__weak YOUR_CUSTOM_CELL *cell = (YOUR_CUSTOM_CELL *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSURLRequest *requestL = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [your_model.url_image stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];
[your_cell.your_image_view setImageWithURLRequest:requestL placeholderImage:[UIImage imageNamed:@"test"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
your_cell.your_image_view.image = image;
} failure:nil];
我希望這將有助於!
它不起作用.. – croigsalvador