Ale*_*lex 2 objective-c cgpoint ios uicollectionview uicollectionviewcell
我有一个CGPoint,我想知道我的集合视图中的哪个单元格当前包含该点.有没有简单的方法可以做到这一点,还是我必须编写自己的方法?
Max*_*iel 12
我没有使用UICollectionView太多,但有一种看似完美的方法:
- (NSIndexPath *)indexPathForItemAtPoint:(CGPoint)point;
Run Code Online (Sandbox Code Playgroud)
传递给方法的点必须位于集合视图的坐标系内.你可以做:
CGPoint convertedPoint = [collectionView convertPoint:point fromView:viewThatYouGotThePointFrom];
Run Code Online (Sandbox Code Playgroud)
如果您获得的点不是最初的集合视图,则获取正确的点.
| 归档时间: |
|
| 查看次数: |
2633 次 |
| 最近记录: |