如何从一个 VC 中包含的一个 VC 过渡到将包含在另一个 VC 中的新 VC?

How to transition from one VC contained in one VC, to a new VC which will be contained in the same VC as the other?

当应用程序启动时,您将从 ViewController(中间的那个)开始。从那里我在右边添加 VC 。当用户点击此 VC 上的按钮时,我希望该视图消失(我目前只需将其框架更改为 900 即可实现),取而代之的是左侧的 VC。

鉴于我不清楚该怎么做,我尝试过的所有事情都失败了。

如何使用这种功能?

假设您引用了容器视图,您可以隐藏和取消隐藏视图,但右侧的 RightViewController 必须与主要的中间部分通信 MiddleViewController

在这里你可以使用Protocols在两者之间进行通信,查看https://medium.com/@nimjea/delegation-pattern-in-swift-4-2-f6aca61f4bf5了解更多详情。

RightViewController tells/delegates MiddleViewController 按钮被点击时

你可以

self.rightContainerView.isHidden = true
self.leftContainerView.isHidden = left

您可以通过以下方式完成此操作:

        if let ViewController2 = segue.destination as? ViewController2 {        
            //here...   
        } else if let viewcontroller = segue.destination as? ViewController1 {
            //here..
        }