Open chrisharrison opened 9 years ago
What to do if you want to navigate from another view by just replacing the center view?
Yes, just execute openCenterController from SlideMoveProtocolDelegate, there you must remove the actual centerViewController and replace it by your new UIViewController
2014-12-21 21:42 GMT-06:00 amcuserguy notifications@github.com:
What to do if you want to navigate from another view by just replacing the center view?
— Reply to this email directly or view it on GitHub https://github.com/wanaya/Slide-Menu/issues/1#issuecomment-67799305.
Thanks for the response. Can you have a sample code for replacing the centerViewController? I have tried removing it by assigning the self.centerViewController to the new UIViewController but its not working.
your response will be much appreciated.
Of course, try something like:
self.centerViewController.view.removeFromSuperview()
self.centerViewController = newController
self.centerViewController.view.tag = centerTag
self.centerViewController.view.bounds = self.view.bounds
self.view.addSubview(self.centerViewController.view)
2014-12-28 23:08 GMT-06:00 amcuserguy notifications@github.com:
Thanks for the response. Can you have a sample code for replacing the centerViewController? I have tried removing it by assigning the self.centerViewController to the new UIViewController but its not working.
your response will be much appreciated.
— Reply to this email directly or view it on GitHub https://github.com/wanaya/Slide-Menu/issues/1#issuecomment-68232790.
@wanaya Thanks for this.. but i'm having difficulty in getting it to work with a new view that replaces the center.
I'm having a difficult time understanding where the below code needs to happen exactly.
self.centerViewController.view.removeFromSuperview() self.centerViewController = newController self.centerViewController.view.tag = centerTag self.centerViewController.view.bounds = self.view.bounds self.view.addSubview(self.centerViewController.view)
Also say if I had a button in the left nav view -- when i click on it, that should invoke the opencenter controller? Like this...
func tapButton() { if let d = self.delegate { d.openCenterController(controller: UIViewController) } }
Yes for replace the center toy need to invoke openCenterController, also the code above is inside the openCenterController method:
func openCenterController(controller: UIViewController) { self.centerViewController.view.removeFromSuperview() self.centerViewController = newController self.centerViewController.view.tag = centerTag self.centerViewController.view.bounds = self.view.bounds self.view.addSubview(self.centerViewController.view) }
I did the following: got an error -- missing argument parameter "nibName" in call. Used the storyboard ID way of instatiating the viewcontroller -- but failed as well.
func openCenterController(controller: UIViewController) {
self.centerViewController.view.removeFromSuperview()
self.centerViewController = AnotherViewController()
self.centerViewController.view.tag = centerTag
self.centerViewController.view.bounds = self.view.bounds
self.view.addSubview(self.centerViewController.view)
}
Wanaya, how can we replace the left side panel with a storyboard and its own controller.
You can do it, making a reference from de uiviewcontroller to the view in the storyboard
Thank you for kind answer, can you scribble a line for me as a start point.. I am really new to swift.. Thanks
Yes you can:
Copy the repository Make a subclass of NavViewController.swift Add a UIViewController to your iPhone's or iPad's storyboard and name it's class to the subclass name and embed it in UINavigationController For the left and right menus, add UIViewControllers and reference the class to the uiviewcontrollers you recently added.
Is an idea.
Can you make this modular so it can be dropped into projects instead of having to import the whole thing?