0

i've connected a push segue from my collectionViewCell to a viewController in storyboard, but when a cell is clicked nothing happens. What do i do in order to accomplish this?

prepareForSegue

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{


    if ([segue.identifier isEqual:@"toHomeProfile"])
    {
        HomeProfileViewController * dvc = segue.destinationViewController;
        self.selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];

    
        dvc.imageArray = [[NSMutableArray alloc]init];
        dvc.imageArray = [imageDic objectAtIndex:self.selectedIndexPath.item];


    }
}

viewDidLoad

- (void)viewDidLoad
{
   [super viewDidLoad];

    CHTCollectionViewWaterfallLayout *layout = [[CHTCollectionViewWaterfallLayout alloc] init];

    layout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
    layout.headerHeight = 0;
    layout.footerHeight = 0;
    layout.minimumColumnSpacing = 5;
    layout.minimumInteritemSpacing = 5;
    self.collectionView.collectionViewLayout = layout;


    _collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    _collectionView.backgroundColor = [UIColor whiteColor];
    [_collectionView registerClass:[CHTCollectionViewWaterfallCell class]
    forCellWithReuseIdentifier:CELL_IDENTIFIER];

}
Community
  • 1
  • 1
  • You shouldn't have to do anything. If the segue was made from the cell, you shouldn't need any code to execute the segue. Just make sure that your call is tappable -- for instance, if it has an image view, make sure you set its userInteractionEnabled to YES (it's NO by default for image views). – rdelmar Aug 31 '14 at 22:05

1 Answers1

0

Check out the collectionView:didSelectItemAtIndexPath: in the UICollectionViewDelegate Protocol

https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionViewDelegate_protocol/Reference/Reference.html

Also, do a quick google before posting! 3 seconds of searching led me to

Handling Tap Gesture in a UICollectionView

Community
  • 1
  • 1
Michael Voznesensky
  • 1,612
  • 12
  • 15