[英]Getting the screen location of a CollectionView cell from a UITableviewCell
我有一個帶有UITableView
的ViewController
,並且在此tableView的每個單元格中,都有一個UICollectionView
。
我想獲取UICollectionView單元格的屏幕位置。
我已經按照本教程構建了視圖:
您可以使用以下方法找到cell
的point
:
let realCenter = collectionView.convert(cell.frame, to: collectionView.superview)
但這是否會使您對collectionView
有所尊重。 如果需要找到相對於main view
的中心,則需要遍歷所有superview
。
let realCenter = collectionView.convert(cell.frame, to: collectionView.superview?.superview?.superview?.superview)
loop
視圖以找到要查找的superview
,然后找到frame
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.