I have created an application in which has two sets of ViewControllers/Storyboards. I would like to go from the orginal ViewController/Storyboard and then load another ViewController/Storyboard after pressing a button. I have tried different things such as this answer but can not figure this out.
Here is the code for the first ViewController:
import UIKit
class HomeController: UIViewController {
@IBAction func enterCottageBuddyApp(_ sender: Any) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Home", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "CottageTabsView") as!
CottageTabsController
self.present(nextViewController, animated:true, completion:nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
And here is the storyboard:
This was the Main.storyboard but I have decided to rename it to Home.storyboard (I Have updated the info.plist to reflect this change and this storyboard loads properly).
Here is the separate ViewController (UITabBarController) I created myself:
import UIKit
class CottageTabsController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
With its Storyboard I added myself as well for the tab bar controller:
I have added these in separate files for a more clean file hierarchy (such as having a storyboard and viewcontroller for the landing page as well as a new storyboard and tabbarcontroller for once a user enters the application). When I click the "Enter App" button on the Home storyboard the app crashes with the error:
'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x600002901f80>) doesn't contain a view controller with identifier 'CottageTabsView''
I made sure to add the Storyboard ID and Restoration ID in the inspector and include them in the action method for the button but I can not seem to make it work no matter what I try. I would like the app to go from the Home.storyboard and HomeController to loading the CottageTabsController and CottageTabs.storyboard.
Thanks!