我在我的应用程序中实现了一个 UICollectionView
。我的问题是我需要选择(就像用户点击它一样)一个单元格以编程方式
。
方法:
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UICollectionViewScrollPosition)scrollPosition
UICollectionView
类的一部分不是我需要调用的,因为此方法不调用:
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
它只是将单元格的selected
属性设置为YES
;
最佳答案
是的,这是正确的行为。 [selectItemAtIndexPath:animated:scrollPosition:]
的文档 says :
This method does not cause any selection-related delegate methods to be called.
关于objective-c - 如何从代码中选择 UICollectionView 的项目/单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13859736/