[英]Getting the screen location of a CollectionView cell from a UITableviewCell
I have a ViewController
with a UITableView
And in each cells of this tableView, I have a UICollectionView
. 我有一个带有
UITableView
的ViewController
,并且在此tableView的每个单元格中,都有一个UICollectionView
。
I would like to get the screen location of a cell of my UICollectionView. 我想获取UICollectionView单元格的屏幕位置。
I've followed this tutorial to build the view: 我已经按照本教程构建了视图:
You can find the point
of your cell
by using: 您可以使用以下方法找到
cell
的point
:
let realCenter = collectionView.convert(cell.frame, to: collectionView.superview)
But if this will give you with respect to the collectionView
. 但这是否会使您对
collectionView
有所尊重。 If you need to find the centre with respect to main view
, you need to go through all the superview
. 如果需要找到相对于
main view
的中心,则需要遍历所有superview
。
let realCenter = collectionView.convert(cell.frame, to: collectionView.superview?.superview?.superview?.superview)
loop
through the views to find your superview
you are looking for and then find the frame
loop
视图以找到要查找的superview
,然后找到frame
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.