0

so I am using a collection view to show an image from my Parse server. When that image is clicked I have two labels on the bottom of the page that show more information (also from the server). The only problem is that these labels are not included in the CollectionView so the user has to tap on the cell for the data to fill those labels. How may I automatically fill those labels with the cell that is presented on the screen? Thank you!

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

PFObject *selectedObject = [labelFileArray objectAtIndex:indexPath.row];
    titleLabel.text = selectedObject[@"labelText"];

    PFObject *selectedObject2 = [mainTextArray objectAtIndex:indexPath.row];
    mainTextLabel.text = selectedObject[@"mainTextLabel"];

}
Nicholas
  • 149
  • 1
  • 13

1 Answers1

0

If I understand your question correctly, your problem is that you want to access the contents of the selected cell so you can put that content in the labels at the bottom of the screen.

In your didSelectItemAtIndexPath, you can use something like:

UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
if (cell)
{
    titleLabel.text = cell.(wherever your content is in the cell)
}

If you need to you can put a tag on the particular content you're interested in and find that view using the tag value. If you want to update your post with the dequeue method I could provide a little more detail if you want it.

RegularExpression
  • 3,531
  • 2
  • 25
  • 36