簡體   English   中英

從UITableviewCell獲取CollectionView單元格的屏幕位置

[英]Getting the screen location of a CollectionView cell from a UITableviewCell

我有一個帶有UITableViewViewController ,並且在此tableView的每個單元格中,都有一個UICollectionView

我想獲取UICollectionView單元格的屏幕位置。

在此處輸入圖片說明

我已經按照教程構建了視圖:

您可以使用以下方法找到cellpoint

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM