0
私は、の再利用可能なセルを持つtableview
に3Dタッチを実装しようとしました。問題は、実際には、セル内のコレクションビューの正しいセルに焦点を合わせることができないということです。ここに私のコードは次のとおりです。3D Touch 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()
}
問題は、私はtableview
の2列目の3Dタッチを適用しようとすると、その後tableview
の前の行のコレクションビューの最初のセルが注目されています。私のアプローチは間違っていると思います。
もちろん、まだテスト段階にあるので、私はまだ適切なコントローラを返さない。