Reputation: 37
When I click they,the function of click(shch as show an alert or get into a new view) works fine but the appearance of the cell I clicked don't change.What I can do to make the cell I click get highlighted ?THX~
Upvotes: 0
Views: 693
Reputation: 3928
Add a public method performSelectionAnimations to the definition of MyCollectionViewCell. Then call it from collectionView:didSelectItemAtIndexPath:
-(void)performSelectionAnimations {
...
...
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
MyCollectionViewCell *cell = (MyCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell performSelectionAnimations];
}
Notice I've taken out the call to [cell setSelected:YES], since that should already be taken care of by the UICollectionView.
Upvotes: 1
Reputation: 2902
You must do it programmatically. Look at :
When you tap on the cell the highlight state change to YES, but you must implement de behaviour (i.e. change background cell on click).
Upvotes: 0