【发布时间】:2015-11-22 09:26:24
【问题描述】:
我有一些正在解析的图像。 (5 个对象每个都有一个 PFFile,每个对象的图像大小约为 800x800 400Kb)。 当我第一次在我的设备(iphone 5S)上运行应用程序时,图像加载,一切正常。 当我向下滚动以加载所有内容时。然后我再次向上爬,图像更早加载(至少一次并通过解析缓存) UICollectionView 闪烁了一下(不是太慢但很明显,就像 UI 试图跟上拖动一样)。 我有什么遗漏的吗?
*编辑 1: 非常感谢对我的代码的任何帮助或改进
调用 CustomCell:
static NSString *cellIdentifier = @"cellImage";
cellTypeImage1 *cell = (cellTypeImage1 *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
[cell configureWithObject:[self.collectionView objectAtIndex:indexPath]];
return cell;
自定义单元格内
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.fullResImage = [[UIImageView alloc] init];
self.fullResImage.frame = CGRectZero;
[self addSubview:self.fullResImage];
}
self.backgroundColor = [color whiteColor];
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
self.fullResImage.frame = CGRectMake(0, 50, self.frame.size.width, self.frame.size.width);
}
- (void)prepareForReuse {
[super prepareForReuse];
self.fullResImage.image = nil;
}
-(void)configureWithObject:(PFObject*)object{
[object[@"image"] getDataInBackgroundWithBlock:^(NSData *data, NSError*error){
if (!error) {
/*THE PROBLEM IS HERE*/
self.fullResImage.image = [UIImage imageWithData:data];
/*When i replace it by a local image [UIImage imageNamed:@"LARGE IMAGE ABOUT 1.2MB"] everything runs smoothly*/
}else{
[ParseErrorHandlingController handleParseError:error];
}}];
}
【问题讨论】:
标签: ios objective-c xcode parse-platform uicollectionview