1

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.

1

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

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?
Check the new controller's view background color property. From memory the default is clearColor, which may be the cause of your confusion.
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)
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.