In my app I use side bar as in facebook. when the user slides out the side bar a uiimageview is displayed. when user taps on the image it takes hm to a different viewcontroller. the problem i am facing is that I have created sidebar programatically and the other view to which I want to navigate the user is created using storyboard. So my source view is created programatically and destination view is created using storyboard. So can someone explain me if there is any way of using "Segue" in this scenario. Since i can not create segue using storyboard I need to do it programatically but even after a lot of googling i could not find the answer.
Asked
Active
Viewed 547 times
1
-
4Possible duplicate of [Make Segue programmatically in Swift](http://stackoverflow.com/questions/35349174/make-segue-programmatically-in-swift) – user6788419 Jan 16 '17 at 10:50
2 Answers
1
Well, to get another instance of another storyboard programmatically you can use something like:
let newController = UIStoryboard(name: "MyStoryboard", bundle: nil).instantiateViewControllerWithIdentifier("MyIdentifier") as! MyViewController
and then you push to your navigation controller, or add as a child view controller or something...
If you don't wanna bother with identifiers you can just use the instantiateInitialViewController
instead of instantiateViewControllerWithIdentifier

Yoam Farges
- 773
- 4
- 16
-
I tried presenting my view controller in the way you specified above but it changes the original color of my view controller. I have unchecked the opaque checkbox but still same issue. any idea? – Tejasvi Tandon Jan 16 '17 at 11:19
-
Check the new controller's view background color property. From memory the default is clearColor, which may be the cause of your confusion. – Yoam Farges Jan 16 '17 at 12:19
0
Might help
"userSB" is the viewcontroller storyboard identifier
@IBAction func tapSearchCriteria(_ sender: Any?) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let aVC = storyboard.instantiateViewController(withIdentifier: "userSB") as? AViewController
aVC?.modalPresentationStyle = UIModalPresentationStyle.custom
aVC?.transitioningDelegate = self
aVC?.udelegate = self
self.present(aVC!, animated: true, completion: nil)
}

rogger2016
- 821
- 3
- 11
- 28