Fun with UICollectionView

Introduced into iOS 6, and like its OS X 10.5 cousin NSCollectionView, I spent some time yesterday with UICollectionView.

I made a PlayingCard View in a PlayingCardGame be a UICollectionViewCell of a UICollectionView.

Here is my tap gesture to the ViewController that flips the playing card:

- (IBAction)flipCard:(UITapGestureRecognizer *)gesture
   CGPoint tapLocation = [gesture locationInView:self.cardCollectionView];
   NSIndexPath *indexpath = [self.cardCollectionView indexPathForItemAtPoint:tapLocation];
   if (indexpath) {
      [ flipCardAtIndex:indexpath.item];
      self.gameResult.score =;
      [self updateUI];

This result is some very clean code.

Tomorrow, Autolayout.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s