bas*_*han 13 objective-c uicollectionview
我有一个集合视图.我想以编程方式选择一个单元格.这是我使用的代码
[_collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:currentSelectedVideo inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionNone];
由于某种原因,功能:
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
未调用,因此我用于显示所选单元格的视觉效果未显示在屏幕上.
这是一种正确的行为吗?
小智 36
你可以做到.
[self.collectionView selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone];
[self collectionView:self.collectionView didSelectItemAtIndexPath:indexPath];
如果只使用selectItemAtIndexPath:animated:scrollPosition:方法,请不要调用委托方法.如果只使用collectionView:didSelectItemAtIndexPath:方法,它不起作用稳定
快乐的代码:)
| 归档时间: | 
 | 
| 查看次数: | 13034 次 | 
| 最近记录: |