Categories
ios swift viewcontroller

Presenting view controllers on detached view controllers

I have sideViewController with a button and Action, which present new view controller by clicking this button.

class sideViewController: UIViewController {
@IBOutlet var buttonVC1 : UIButton!
@IBAction func goToVC1 () {
var VC1 = self.storyboard.instantiateViewControllerWithIdentifier("ViewController") as ViewController
presentViewController(VC1, animated:true, completion: nil)
}
}

I use this in main view controller:

class ViewController: UIViewController {
var menu : sideViewController!
override func viewDidLoad() {
super.viewDidLoad()
menu = self.storyboard.instantiateViewControllerWithIdentifier("menu") as sideViewController
menu.view.frame = CGRect(x: 0, y: 0, width: 160, height: 480)
view.addSubview(menu.view)
}

when I click this button, the problem is: “Presenting view controllers on detached view controllers is discouraged”

What should I do to fix this?