0
나는 을 가진 재사용 가능한 셀을 가진 tableview
에서 3D 터치를 구현하려고 시도했다. 문제는 셀의 콜렉션 뷰의 올바른 셀에 초점을 맞출 수 없다는 것입니다. 그때 tableview
의 이전 행의 콜렉션 뷰의 첫 번째 셀에서 초점을 맞추고있는 tableview
의 두 번째 행에 3D 터치를 적용하려고하면3D 터치 UICollectionView insideUITableviewCell
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }
guard let cell = tableView.cellForRow(at: indexPath) as? DiscoveryComponent else { return nil }
let collectionView = cell.collectionView
print("---- CollectionView \(collectionView)----")
let collectionPoint = collectionView.convert(location, from: tableView)
guard let collectionIndexPath = collectionView.indexPathForItem(at: collectionPoint) else { return nil }
guard let collectionViewCell = collectionView.cellForItem(at: collectionIndexPath) as? DiscoveryProductCell else { return nil }
print(collectionIndexPath)
print("Collection Cell \(collectionViewCell.productImageView.frame)")
previewingContext.sourceRect = collectionViewCell.productImageView.frame
return UIViewController()
}
문제는 : 여기 내 코드입니다. 나는 나의 접근 방식이 잘못되었다고 생각한다.
물론 아직 테스트 단계에 있기 때문에 결국 적절한 컨트롤러를 반환하지 않습니다.