-
Notifications
You must be signed in to change notification settings - Fork 2.2k
How to get ASCellNode's frame in it's container #2986
Comments
Sure! You should convert the rect: CGRect nodeFrame = [collectionNode convertRect:cellNode.bounds fromNode:cellNode] |
func collectionNode(_ collectionNode: ASCollectionNode, didSelectItemAt indexPath: IndexPath) {
if let cellNode = collectionNode.nodeForItem(at: indexPath) {
let nodeFrame = collectionNode.convert(cellNode.bounds, from: cellNode)
print(nodeFrame.origin) // This will be equal to 0.0, 0.0
}
} |
I actually get non zero values for: But I want to convert this frame to screen coordinates (for This both doesn't make sense to me since in this example the view debugger gives me an origin of |
@jauzee was your issue resolved? If not could you reopen it? Otherwise I'll open another issue |
@fruitcoder sorry, I didn't see your message. Now I was trying to solve this problem again, because in func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
let collectionNode = node.collectionNode
guard
let indexPath = collectionNode.indexPathForItem(at: location),
let targetCell = collectionNode.view.visibleCells
.first(where: { $0.frame.contains(location) }) else {
return nil
}
previewingContext.sourceRect = targetCell.frame
...
} |
@jauzee @Adlai-Holler @fruitcoder @levi @JoelMarcey This issue is closed without any proper solution. |
If we get a
cell
fromUICollectionView
orUITableView
it will have appropriateframe
with right origin within the container, but origin point ofASCellNode
that we got fromASCollectionNode
orASTableNode
always equals to zero. I want to know this frame to change other subnode's frame in the container (ASColletionNode
). Can I do this?ASDK
version: 2.0.2The text was updated successfully, but these errors were encountered: