在 PFQueryCollectionViewController 中首次加载时未出现图像
Images not appearing on first load in PFQueryCollectionViewController
有没有人得到一个 PFQueryCollectionViewController 来加载图像Objective C?
当用户首次加载视图时,它将加载文本,但不会加载图像。用户第二次加载视图时,图像被加载。没看懂。
- (PFCollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object {
PFCollectionViewCell *cell = [super collectionView:collectionView cellForItemAtIndexPath:indexPath object:object];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.text = object[@"name"];
cell.imageView.file = object[@"icon"];
// If the image is nil - set the placeholder
if (cell.imageView.image == nil) {
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
[cell.imageView loadInBackground];
}
cell.contentView.layer.borderWidth = 1.0f;
cell.contentView.layer.borderColor = [UIColor clearColor].CGColor;
return cell;
}
该行为与 imageView.image 最初是 non-nil 一致。只需无条件地执行占位符分配。一旦图像被缓存,占位符将被真实图像的分配撤消(在绘制任何东西之前)...
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
cell.imageView.file = object[@"icon"];
[cell.imageView loadInBackground];
有没有人得到一个 PFQueryCollectionViewController 来加载图像Objective C?
当用户首次加载视图时,它将加载文本,但不会加载图像。用户第二次加载视图时,图像被加载。没看懂。
- (PFCollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object {
PFCollectionViewCell *cell = [super collectionView:collectionView cellForItemAtIndexPath:indexPath object:object];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.text = object[@"name"];
cell.imageView.file = object[@"icon"];
// If the image is nil - set the placeholder
if (cell.imageView.image == nil) {
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
[cell.imageView loadInBackground];
}
cell.contentView.layer.borderWidth = 1.0f;
cell.contentView.layer.borderColor = [UIColor clearColor].CGColor;
return cell;
}
该行为与 imageView.image 最初是 non-nil 一致。只需无条件地执行占位符分配。一旦图像被缓存,占位符将被真实图像的分配撤消(在绘制任何东西之前)...
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
cell.imageView.file = object[@"icon"];
[cell.imageView loadInBackground];