Question

I have a basic UICollectionView set up with 5 version of the cell. The cells populate fine. What I want to do is have each version segue to a certain view in the Storyboard (a view which I have given an ID). Is there a way to do this? I have this code which counts the number of items in the controller, however, I will always know and control how many items are in it:

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return videoList.count;

Is there some sort of switch I can use to have the first cell go to one UIViewController, and have the second go another? Thanks

Was it helpful?

Solution

You can use the indexPath.item as the switch. In collectionView:didSelectItemAtIndexPath:, put in if-else statements (or a switch statement) to go to different controllers based on the indexPath.item of the cell you selected.

OTHER TIPS

You should be able to control this in your UICollectionViewDelegate class, specifically the collectionView:didSelectItemAtIndexPath: method. In here you can use the indexPath.item to determine which cell they touched, then call a [self performSegueWithIdentifier:sender:] to control where in the storyboard it goes next.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top