Reputation: 187
Does anyone know how I can implement a sidebar slide menu in an exiting app (without using storyboard)?
I have found SWRevealViewController
, but all instructions are for a new app and an app with storyboards. I can't find any instructions for implementing it in an existing app, nor instructions for implementing it without storyboards.
I have a UINavigationControler
with a rootViewController
which is a tableViewController
, but now I want to add a sidebar menu to the app.
Upvotes: 1
Views: 4028
Reputation: 505
You can use InteractiveSideMenu library. There are menuViewController
and contentViewControllers
members of class MenuContainerViewController
that that can be instantiated from code.
Here is an example:
class HostViewController: MenuContainerViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.menuViewController = YourMenuViewController()
self.contentViewControllers = [YourContentViewController()]
self.selectContentViewController(contentViewControllers.first!)
}
}
Upvotes: 2
Reputation: 1859
Try it in Swift 3. Hope it help.
let frontViewController = NavigationController() // UINavigationController
let rearViewController = MenuController() // display slide menu
let revealController = SWRevealViewController(rearViewController: rearViewController, frontViewController: frontViewController)
revealController?.toggleAnimationType = SWRevealToggleAnimationType.easeOut
revealController?.toggleAnimationDuration = 0.30
viewControllers = [revealController!]
UIApplication.shared.keyWindow?.rootViewController = revealController
Upvotes: 0
Reputation: 305
you are going in right way, you need to push on SWRevealViewController class from your login button and hide uinavigaiton back button by this code.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {self.navigationController.navigationBar.hidden = YES; }
Upvotes: 0
Reputation: 297
Please find link below , you will find plenty of uicontrols here that enables you to implement sidemenu programmatically.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=side+menu
Upvotes: 1