maxn00b
maxn00b

Reputation: 1

How to setup each uicollectionview cell to open new view with corresponding text

so I have my uicollectionview setup with 40 cells. What I would like to do is when a cell is tapped it opens new view with 2 labels, each with 40 corresponding different texts. So I'm thinking of having NSArray1 for label1 NSArray2 for label2 Then get labels to check index of cell and display its text at that index. Is this possible? Thanks

Upvotes: 0

Views: 389

Answers (1)

Anil Varghese
Anil Varghese

Reputation: 42977

You can do it easily. So far your thought is in the right direction. Keep data in arrays(use a dictionary will be better since you can avoid two different arrays and get a well structure) and keep track of the selected index of the item.

You have create a property in the detailViewController to store the selected item number.

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

    DetailViewController *detailViewController = [[DetailViewController alloc]init];
    detailViewController.selectedItem = indexPath.row;
    [self.navigationController pushViewController:detailViewController animated:YES];

    [detailViewController release];
}

Upvotes: 1

Related Questions