0

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~

4

2 回答 2

1

在 MyCollectionViewCell 的定义中添加公共方法 performSelectionAnimations。然后从 collectionView:didSelectItemAtIndexPath 中调用它:

-(void)performSelectionAnimations {

...


...
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
MyCollectionViewCell *cell = (MyCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell performSelectionAnimations];
}

请注意,我已经取消了对 [cell setSelected:YES] 的调用,因为 UICollectionView 应该已经处理好了。

于 2013-10-11T05:27:06.700 回答
0

您必须以编程方式进行。看着 :

https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CollectionViewPGforIOS.pdf#page18

当您点击单元格时,突出显示状态变为“是”,但您必须实现 de 行为(即单击时更改背景单元格)。

于 2013-10-11T05:03:08.780 回答