I have a MainViewController.swift and it is connected to a Xib File (called MainViewController). The MainViewController is connected to a MenuViewController.swift and its Xib(called MenuViewController). The MainViewController calls the MenuViewContoller using the following code,
override func viewDidLoad() {
super.viewDidLoad()
...
menuBtn.addTarget(self, action: #selector(callMenuModal), forControlEvents: .TouchUpInside)
....
}
func callMenuModal() {
let menuVC = MenuViewController()
menuVC.delegate = self
menuVC.modalPresentationStyle = .OverCurrentContext
presentViewController(menuVC, animated: false, completion: nil)
}
.......
func backFromMenu() {
self.dismissViewControllerAnimated(true, completion: nil)
}
...
...
My friends have made a story board with a lot of Segues and ViewControllers.
I have to now load my .xib file and its corresponding view controller when a button is pressed from a ViewController on the story board. I have looked high and low for a solution and could not find one.
Previously I called my xib directly from the AppDelegate so I didn't have to do any thing. I had only one view controller in the story board and an app delegate for the whole app, the code I used in the delegate is as given below,
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainViewController = MainViewController(nibName: "MainViewController", bundle: nil)
window?.rootViewController = mainViewController
window?.makeKeyAndVisible()
return true
}
........rest of app delegate....
But I don't know how to load that xib file, from a different view controller in the storyboard or a button press(IBAction) from a ViewController.