I'm trying to use the project SideMenu (https://github.com/jonkykong/SideMenu) inside my Objective-C code (I saw the @objc/@objcMembers syntax so I'm guessing it should be possible) and I'm not using storyboards. Can the controller be used in this scenario? If so, how? It seems I correctly imported the module as I'm able to see the classes with autocompletion, but if I try to instantiate a SideMenuNavigationController, I cannot access the initWithRootViewController method. Is there anybody who could point me in the right direction? Thanks
SideMenu: How to include in Objective-C project?
290 Views Asked by zionun At
2
There are 2 best solutions below
0
On
Here is the solution I adopted, in case someone was running into the same problem. In your pod file, use this fork of the SideMenu project:
pod 'SideMenu', :git => 'https://github.com/DanielFontes/SideMenu.git', :commit => '52361cfee8cd89698cc131729d9f337d8fafcffe';
Then, you can instantiate SideMenu as you normally would with an Objective-C class; here is how I configured it in my project:
YourViewController *_view = [[YourViewController alloc] initWithNibName:@"NibName" bundle:nil];
SideMenuSettings *_settings = [[SideMenuSettings alloc] init];
[_settings setPresentationStyle:SideMenuPresentationStyle.menuSlideIn];
SideMenuPresentationStyle *_selectedPresentationStyle = _settings.presentationStyle;
_selectedPresentationStyle.presentingScaleFactor = 0.9;
float width = (self.isiPad)?570:300;
[_settings setMenuWidth:width];
SideMenuNavigationController *_sideMenu = [[SideMenuNavigationController alloc] initWithRootViewController:_view settings:_settings];
[_sideMenu setSideMenuDelegate:self];
[_sideMenu setNavigationBarHidden:YES];
[_sideMenu setLeftSide:YES];
[_sideMenu setStatusBarEndAlpha:0];
[[SideMenuManager defaultManager] setLeftMenuNavigationController:_sideMenu];
[[SideMenuManager defaultManager] addPanGestureToPresentToView:_firstViewController.navigationController.navigationBar];
[[SideMenuManager defaultManager] addScreenEdgePanGesturesToPresentToView:_firstViewController.view];
Not sure if you already figured this out, but in Objective-C, the class is exposed as
UISideMenuNavigationControllerinstead. So, you end up with: