有没有人得到一个 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;
}