0

I have 2 viewControllers:

  1. VC1
  2. VC2

(VC2 presented on top of VC1)

I need to know in advance the (CGPoint) position of a subview of VC1 whenever I am in VC2 so that I can apply an animation dismissing VC2.

I thought about implementing delegates and protocols and this is what I have done:

protocol PreviewCapturedViewControllerDelegate {
    func retrieveIconPosition() -> CGPoint
    func goToProfilePosition()
}

But I actually don't know how to retrieve the position of the view using this protocol.

  • For getting the coordinate of VC1 subview relative to VC2, you can reference this [Get Position of UIView within entire UIWindow](https://stackoverflow.com/questions/1465394/iphone-get-position-of-uiview-within-entire-uiwindow). – Cosmos Man Aug 21 '20 at 09:41
  • @CosmosMan Thanks for the answer, the problem is that VC2 is not a subview of VC1, it is actually presented over it –  Aug 21 '20 at 12:20

1 Answers1

0

I solved this problem using protocols and delegates: when you present VC2 you pass the CGPoint coordinate, then you use it in VC2 when dismissing it to animate