답변

10

나는 많은 UICollectionView의 사용하지 않은,하지만 완벽하게 보이는 방법이있다 : 당신이 방법에 전달

- (NSIndexPath *)indexPathForItemAtPoint:(CGPoint)point; 

점은 컬렉션 뷰의 좌표 시스템 내이어야한다가. 당신은 할 수 있습니다 : 당신이있어 포인트가 원래 컬렉션보기 아닌 경우

CGPoint convertedPoint = [collectionView convertPoint:point fromView:viewThatYouGotThePointFrom]; 

는 정확한 포인트를 얻을 수 있습니다.

+0

고마워요. 정확히 내가 염두에 두었던 것! – Alex

0
//due to the point passed in possibly not containing a cell IndexPath is an optional 

      func indexPathForCellAtPoint(_ point : CGPoint) -> IndexPath? { 
       return collectionView?.indexPathForItem(at: self.view.convert(point, to: collectionView!)) 
      } 

override func scrollViewDidScroll(_ scrollView: UIScrollView) { 
      let topLeftCell = CGPoint(x: 1, y: 60) 
      if let indexPath = indexPathForCellAtPoint(topLeftCell) { 
       print(indexPath.section,indexPath.row) 
      } 
    } 
관련 문제