Open sahabe1 opened 7 years ago
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let newController = storyboard.instantiateViewController(withIdentifier: "ProfileViewController")
// replace the identifier with whatever you call your menu
let leftViewController = storyboard.instantiateViewController(withIdentifier: "Left")
let slideMenuController = SlideMenuController(mainViewController: newController, leftMenuViewController: leftViewController)
// navigate to next view
self.present(slideMenuController, animated: false, completion: nil)
@Vrezhg if you repeat this will those controllers pile up in memory? Genuinely curious.
That's a fair question but one that I can't answer. I suppose depending on how strong of a reference the program holds to these variables. Its my understanding that as soon as there is no longer something referring to the old view controllers that it should be removed from memory. Just a theory I could be wrong
Sent from my iPhone
On Apr 16, 2017, at 12:59 AM, Charles C. notifications@github.com wrote:
@Vrezhg if you repeat this will those controllers pile up in memory? Genuinely curious.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
If there was a way to do an unwind on this style of instantiation...
I am a newbie in both ios development and swift 3, so I don't know if my method to pushViewController from side menu is good or bad in terms of development; but it works. Here is what I did.
Use this inside your viewcontroller:
self.slideMenuController()?.changeMainViewController(controller, close: true)
Full example:
class MenuViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func homePressed(sender: UIButton) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "HomeNav") {
self.slideMenuController()?.changeMainViewController(controller, close: true)
}
}
@IBAction func favoritesPressed(sender: UIButton) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "FavoritesNav") {
self.slideMenuController()?.changeMainViewController(controller, close: true)
}
}
}
Hi I want to push controller from side menu but its not working here is my code
let profileController = storyboard.instantiateViewController(withIdentifier: "ProfileViewController") as! ProfileViewController self.slideMenuController()?.toggleLeft() self.navigationController?.pushViewController(profileController, animated: true)
can help me how i can push contoller