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) {
      [self.game flipCardAtIndex:indexpath.item];
      self.flipCount++;
      self.gameResult.score = self.game.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:

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s