wanaya / Slide-Menu

Slide Menu in swift
24 stars 6 forks source link

Modular #1

Open chrisharrison opened 9 years ago

chrisharrison commented 9 years ago

Can you make this modular so it can be dropped into projects instead of having to import the whole thing?

amcuserguy commented 9 years ago

What to do if you want to navigate from another view by just replacing the center view?

wanaya commented 9 years ago

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.

amcuserguy commented 9 years ago

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.

wanaya commented 9 years ago

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.

gbertb commented 9 years ago

@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) } }

wanaya commented 9 years ago

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) }

gbertb commented 9 years ago

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)

}
kbirand commented 9 years ago

Wanaya, how can we replace the left side panel with a storyboard and its own controller.

wanaya commented 9 years ago

You can do it, making a reference from de uiviewcontroller to the view in the storyboard

kbirand commented 9 years ago

Thank you for kind answer, can you scribble a line for me as a start point.. I am really new to swift.. Thanks

wanaya commented 9 years ago

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.