@objc func handleGoToSearch() {
// present(UINavigationController(rootViewController: searchDisplayController()), animated: true, completion: nil)
performSegue(withIdentifier: "searchSegue", sender: nil)
}
I was using the present call to SearchViewController but the ib outlets on where nil, I have a feeling it has something to do with passing a new instance, and the outlets are not loading in time. (What I read somewhere else). when I use perform segue not errors.
I would like to know exactly what's happening. I also thought that maybe present() doesn't work with storyboard, or I'm passing in the wrong value type.
Your outlets are nil because you are not creating the viewcontroller from the Swift class only, not from the storyboard. To create the viewcontroller from the storyboard, do this:
let viewController = UIStoryboard(name: "Name of the storyboard").instantiateViewController(withIdentifier: "Identifier of the viewcontroller")
You should fill in the name of the storyboard (usually Main
) and give the viewcontroller an identifier in the storyboard, and use that identifier in the code.