如何将 menuType 连接到另一个 viewcontroller?

How do I connect a menuType to another viewcontroller?

我想将下面的 .merchant 菜单选项 link 添加到另一个我为 UI 设计的视图控制器,非模态。我感觉它与 Subview 和连接我的 MerchantViewController 有关。我不想添加按钮,我想使用这些“案例”。非常感谢,先post.

本视频中提到了可能的 childviewcontroller 解决方案:https://youtu.be/vKh1b3ctCf4?t=556

func transitionToNew(_ menuType: MenuType) {
        topView?.removeFromSuperview()
        switch menuType {
        case .profile:
            let view = UIView()
            view.backgroundColor = .yellow
            view.frame = self.view.bounds
            self.view.addSubview(view)
            self.topView = view
        
        case .camera:
            let view = UIView()
            view.backgroundColor = .blue
            view.frame = self.view.bounds
            self.view.addSubview(view)
            self.topView = view
        
        //I want .merchant to link to a MerchantViewController
        case .merchant:
            let view = UIView()
            //view.backgroundColor = .blue
            view.frame = self.view.bounds
            self.view.addSubview(view)
            self.topView = view
        
        default:
            break

您可以将商家 ViewController 添加为当前视图控制器的子项。

let merchantVC = MerchantViewController()  //setup MerchantViewController
let merchantView = merchantVC.view
self.view.addSubview(merchantView)
self.addChild(merchantVC)
merchantVC.didMove(toParent: self)
self.topView = merchantView