0

I am a beginner on Xcode and I am trying to embed YouTube video to child controllers of a side menu, but I can't connect my view controller file and my UI view controllers on the storyboard. I am coding a side menu controller and the child views controllers are called using:

class Course2ViewController: UIViewController, MenuControllerDelegate2 {
    private var sideMenu: SideMenuNavigationController?
    
    private let abaController = abaViewController()
    private let abbController = abbViewController()
    private let abcController = abcViewController()
    private let abdController = abdViewController()
    

    override func viewDidLoad() {
        super.viewDidLoad()
        let menu = MenuController2(with: SideMenuItem2.allCases)
        
        menu.delegate = self
        
        sideMenu = SideMenuNavigationController(rootViewController: menu)
        sideMenu?.leftSide = true
        
        SideMenuManager.default.leftMenuNavigationController = sideMenu
        SideMenuManager.default.addPanGestureToPresent(toView: view)

        AddChildControllers()
    }
    
    private func AddChildControllers() {
        addChild(abaController)
        addChild(abbController)
        addChild(abcController)
        addChild(abdController)
        
        view.addSubview(abaController.view)
        view.addSubview(abbController.view)
        view.addSubview(abcController.view)
        view.addSubview(abdController.view)
        
        abaController.view.frame = view.bounds
        abbController.view.frame = view.bounds
        abcController.view.frame = view.bounds
        abdController.view.frame = view.bounds
        
        abaController.didMove(toParent: self)
        abbController.didMove(toParent: self)
        abcController.didMove(toParent: self)
        abdController.didMove(toParent: self)
        
        abaController.view.isHidden = true
        abbController.view.isHidden = true
        abcController.view.isHidden = true
        abdController.view.isHidden = true
    }
    
    @IBAction func didTapMenuButton2() {
        present(sideMenu!, animated: true)
    }
    
    func didSelectMenuItem2(named: SideMenuItem2) {
        sideMenu?.dismiss(animated: true, completion: nil)
        
            title = named.rawValue
            switch named {
        case.aba:
                abaController.view.isHidden = false
                abbController.view.isHidden = true
                abcController.view.isHidden = true
                abdController.view.isHidden = true
            
        case.abb:
                abaController.view.isHidden = true
                abbController.view.isHidden = false
                abcController.view.isHidden = true
                abdController.view.isHidden = true
            
        case.abc:
                abaController.view.isHidden = true
                abbController.view.isHidden = true
                abcController.view.isHidden = false
                abdController.view.isHidden = true
        
        case.abd:
                abaController.view.isHidden = true
                abbController.view.isHidden = true
                abcController.view.isHidden = true
                abdController.view.isHidden = false
            }
    }

}

then, I tried to connect my abaViewController file to a new view controller on storyboard by giving the later the class "abaViewController", but my view controller on storyboard is not displayed. Any tips/solutions?

AIRONE
  • 13
  • 3

1 Answers1

0

Here's a look at how to create a Story Board directly from Swift UI

If you're finding SwiftUI a little too complicated to begin with (most people do) I really recommend choosing 'Storyboard' or 'UIKit' on your next project. It allows you to easily add view controllers and quickly allow buttons to move to other view controllers by just holding the button, then 'Control', then the new screen. UIKit also allows you to manage every aspect of your design visually (also managing formatting and constraints) without a single line of code. What's even better is that you can combine both SwiftUI and UIKit together.

    let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
// Alternative way to present the new view controller
self.navigationController?.showViewController(vc, sender: nil)
starball
  • 20,030
  • 7
  • 43
  • 238
New_Dev
  • 1
  • 3