在我的应用程序中,我有以下代码:
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return images.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"gallerycell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *backImageCell = (UIImageView*)[cell viewWithTag:100];
[backImageCell setImage:[images objectAtIndex:indexPath.item]];
if([indexPath row] == ((NSIndexPath*)[[collectionView indexPathsForVisibleItems] lastObject]).row){
[activity_view stopAnimating];
[UIView animateWithDuration:0.8 animations:^{
back.alpha = 0;
}];
}
return cell;
}
数组 images 包含 200x150 大小的 UIImage,它们以 kb 为单位的尺寸约为 42kb,一个普通的 UIImage 数组。
当我为此 collectionview 重新加载数据时,我在 15 张图像后出现内存警告......有没有办法(作为线程)没有内存警告?