UICollectionView如何从Parse查询
UICollectionView how to query from Parse
我有 UICollectionView,我需要将图像下载到 UIImage 单元格。我怎样才能用 Parse 做到这一点?事实是我需要 class 解析下载所有图像。
这是我的源代码示例:
- (void)runQuery {
PFQuery *query = [PFQuery queryWithClassName:@"SwapPost"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// You obviously need better error handling in here...
self.myImage = objects;
[self.myCollectionView reloadData];
}
];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
// This is an assumption
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.myImage.count;
}
此代码修复的问题:
(NSInteger)numberOfSectionsInCollectionView:
(UICollectionView *)collectionView {
// This is an assumption
return [receivedObject count];
}
(NSInteger)collectionView:
(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
self.imageCell.image = [NSArrayName objectAtIndex:indexPath.row];
}
我有 UICollectionView,我需要将图像下载到 UIImage 单元格。我怎样才能用 Parse 做到这一点?事实是我需要 class 解析下载所有图像。
这是我的源代码示例:
- (void)runQuery {
PFQuery *query = [PFQuery queryWithClassName:@"SwapPost"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// You obviously need better error handling in here...
self.myImage = objects;
[self.myCollectionView reloadData];
}
];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
// This is an assumption
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.myImage.count;
}
此代码修复的问题:
(NSInteger)numberOfSectionsInCollectionView:
(UICollectionView *)collectionView {
// This is an assumption
return [receivedObject count];
}
(NSInteger)collectionView:
(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
self.imageCell.image = [NSArrayName objectAtIndex:indexPath.row];
}