Reputation: 117
I have tried to set root view controller for a navigation controller with viewcontoller name only. But i got only with storyboard id only. Please help me with this
let story = UIStoryboard.init(name: "Main", bundle: nil)
let vc = story.instantiateViewController(withIdentifier: "MyTaskVC")
self.navigationController?.pushViewController(vc, animated: true)
Upvotes: 0
Views: 2528
Reputation: 949
Try this,
let story = UIStoryboard(name: "Main", bundle: nil)
let vc = story.instantiateViewController(withIdentifier: "MyTaskVC")
let navController = UINavigationController(rootViewController: vc)
Upvotes: 1
Reputation: 135
Don't think it is possible but see if the below helps. You will need an identifier "String" to perform a segue/push. Its a segue identifier not a storyboard identifier so be cautious!
//Segue
performSegue(withIdentifier: "Put your segue identifier name here", sender: nil)
If you have a storyboard ID then,
//Push
let storyID = UIStoryboard(name: "your main storyboard name", bundle:nil)
let someview = storyID.instantiateViewController(withIdentifier: "someview_Controller_name") as! someview_Controller_name
navigationController?.pushViewController(someview_Controller_name, animated: true)
Upvotes: 1