【发布时间】:2015-02-28 14:31:41
【问题描述】:
我通过填充“imageFilesArray”并告诉 UICollectionViewCells 使用其数据来加载登录用户在先前视图控制器中选择的特定图像的“房间”UICollectionView:
-(void) retrieveSelectedImagesForRooms
{
//parse query where we search the selectedImage array column and return any entry where the array contains the logged in user objectid
PFQuery *getRooms = [PFQuery queryWithClassName:@"collectionViewData"];
[getRooms whereKey:@"selectedImage" equalTo:[PFUser currentUser].objectId];
[getRooms findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
imageFilesArray = [[NSArray alloc] initWithArray:objects];
[roomsCollection reloadData];
}
}];
}
下一页必须显示用户为之前选择的房间图像选择的特定灯光。 So I add the row's objectid I've just selected to a new column on Parse, called "clickedRoom", when the room is selected:
-(void)selectedRoom:(PFObject*)object
{
[object addUniqueObject:object.objectId forKey:@"clickedRoom"]; //put object id into clickedRoom column on Parse to save what room you specifically chose so that the light images correspond to only that room
[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (!error){}
else{}
}];
}
- (void)collectionView:(UICollectionView*)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self selectedRoom:[imageFilesArray objectAtIndex:indexPath.row]];
[self performSegueWithIdentifier:@"myLights" sender:self];
}
现在,在“灯光”页面中,我只需要在“clickedRoom”列中显示具有所选房间的 objectid 的灯光图像。我相信这与我检索房间图像的原理相同,但我无法弄清楚我应该查询什么,例如:
-(void) retrieveCorrespondingImagesForLights
{
PFQuery *getLights = [PFQuery queryWithClassName:@"collectionViewData"];
[getLights whereKey:@"clickedRoom" equalTo:**MY-PREVIOUSLY-SELECTED-ROW**.objectid];
[getLights findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
imageFilesArray = [[NSArray alloc] initWithArray:objects];
[myLightsCollection reloadData];
}
}];
}
有什么建议吗?!
【问题讨论】:
标签: ios objective-c xcode parse-platform uicollectionviewcell