Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It would appear that you are obtaining the wrong Cell. Sending the <code>dequeueReusableCellWithReuseIdentifier:forIndexPath:</code> message does <em>not</em> obtain the cell in use in the view at the indexPath in the second parameter, but dequeues a previously used but reusable cell; if no reusable cell is available, a new one is created. See Reference 1 below. </p> <p>Replacing:</p> <pre><code>ProductCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ProductReuseID" forIndexPath:indexPath]; </code></pre> <p>With:</p> <pre><code>ProductCollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath]; </code></pre> <p>In your code above, should give you the proper cell to work with.</p> <p>Here is your fist example, rewritten. </p> <pre><code>- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath(NSIndexPath *)indexPath { // animate the cell user tapped on UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; [UIView animateWithDuration:5.0 delay:0 options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ NSLog(@"animation start"); [cell setBackgroundColor:[UIColor colorWithRed: 180.0/255.0 green: 238.0/255.0 blue:180.0/255.0 alpha: 1.0]]; } completion:^(BOOL finished){ NSLog(@"animation end"); [cell setBackgroundColor:[UIColor whiteColor]]; } ]; } </code></pre> <p>References:</p> <ul> <li><a href="http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html#//apple_ref/occ/cl/UICollectionView" rel="noreferrer">http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html#//apple_ref/occ/cl/UICollectionView</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload