【发布时间】:2012-12-13 12:19:48
【问题描述】:
我在我的应用中实现了UICollectionView。我的问题是我需要选择(就像用户点击它一样)一个单元格programmatically。
方法:
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UICollectionViewScrollPosition)scrollPosition
这是UICollectionView 类的一部分,我不需要调用它,因为这个方法不会调用:
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
它只是将单元格的selected 属性设置为YES;
【问题讨论】:
-
选择单元格后自己调用方法怎么样?你可以调用 [self collectionView:yourView didSelectItemAtIndexPath:yourIndexPath];
-
也许这个答案会对你有所帮助stackoverflow.com/questions/13177201/…
-
@ДилянаТодорова 是的。谢谢!我知道
didSelectItemAtIndexPath一个,但我正在寻找一种不属于UICollectionView Delegate Protocol的方法。我想到了。现在一切正常。
标签: objective-c ios ipad uicollectionview uicollectionviewcell