Reputation: 25
Looking for a solution on perform a segue from a viewcontroller (VC2) that is embedded in a container view and replace it with the next viewcontroller (VC3) maintaining same size of VC2.
I proceed to setup the controller according this that is exactly what i'm looking for:
Container view segue to same size view controller
I set the segue from VC2 to VC3 as Modal segue using current context mode from storyboard or programmatically but the VC3 still loading full screen
thanks
Upvotes: 1
Views: 736
Reputation: 939
Inside the viewDidLoad of VC2 add this:
definesPresentationContext = true
The reason it wasn't working is because when you set a segue to currentcontext it searches up the view controller stack looking for a view controller that has definesPresentationContext set to true. The view controller that it finds is the one that gets replaced.
More on this here: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621456-definespresentationcontext
If no view controller with definesPresentationContext = true is found then the VC3 will be presented on the window. This is why it was still full screen.
Also the reason is was working on a navigation stack is because navigation controllers are the only view controllers with definesPresentationContext = true by default
Upvotes: 0