1
votes

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

1
Solved: I embed the VC2 in a UINavigationcontroller and change the segue between VC2 and VC3 to pushAlberto Lunardini
You know you could just write an answer and accept it instead of putting a comment and changing your question title.takendarkk
@AlbertoLunardini You should write your answer as the solution to your question. This helps to mark this problem as solved and others might be able to solve their problems too! :)Alex Cio

1 Answers

0
votes

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