侧菜单:如何包含在Objective-C项目中?

侧菜单:如何包含在Objective-C项目中?,objective-c,swift,side-menu,Objective C,Swift,Side Menu,我试图在我的Objective-C代码中使用project SideMenu()(我看到了@objc/@objcMembers语法,所以我猜这应该是可能的),我没有使用故事板。 在这种情况下可以使用控制器吗?如果是,怎么做? 似乎我正确地导入了模块,因为我可以通过自动完成查看类,但是如果我尝试实例化SideMenugationController,我无法访问initWithRootViewController方法。 有人能给我指出正确的方向吗? 谢谢我不确定您是否已经解决了这个问题,但是在Obj

我试图在我的Objective-C代码中使用project SideMenu()(我看到了@objc/@objcMembers语法,所以我猜这应该是可能的),我没有使用故事板。 在这种情况下可以使用控制器吗?如果是,怎么做? 似乎我正确地导入了模块,因为我可以通过自动完成查看类,但是如果我尝试实例化SideMenugationController,我无法访问initWithRootViewController方法。 有人能给我指出正确的方向吗?
谢谢

我不确定您是否已经解决了这个问题,但是在Objective-C中,该类被公开为
UISideMenunigationController
。因此,你最终会:

UISideMenuNavigationController *menu = [[UISideMenuNavigationController alloc] initWithRootViewController:controller];

这是我采用的解决方案,以防有人遇到同样的问题。 在pod文件中,使用SideMenu项目的以下分支:

pod 'SideMenu', :git => 'https://github.com/DanielFontes/SideMenu.git', :commit => '52361cfee8cd89698cc131729d9f337d8fafcffe';
然后,您可以像通常使用Objective-C类那样实例化侧菜单;以下是我在项目中如何配置它:

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];


在swift中,它将是:
SideMenuNavigationController(rootViewController:YourViewController)
SideMenuNavigationController.init(rootViewController:YourViewController)
是的,这是我在文档中找到的。在Obj-C中,我会使用rootViewController:YourViewController执行
[[SideMenunigationController alloc]初始化]
,但它无法识别该方法,即使Swift代码中有@objcMembers声明。有什么想法吗?嗨,杰里米,谢谢你的建议。不幸的是,我在尝试您的解决方案时出错:
'initWithRootViewController:'不可用未知接收器'UISideMenuNavigationController';你是说“SideMenunigationController”吗?将“UISIDEMENUGATIONCONTROLLER”替换为“SIDEMENUGATIONCONTROLLER”
将UISIDEMENUGATIONCONTROLLER替换为SIDEMENUGATIONCONTROLLER会导致错误:
“initWithRootViewController:”不可用
@zionun:您找到解决方案了吗?我面临同样的问题。@DaxeshNagar是的,我使用了项目的一个分支。您可以像这样将其放入pod文件:
pod'SideMenu',:git=>'https://github.com/DanielFontes/SideMenu.git“,:commit=>“52361cfee8cd89698cc131729d9f337d8fafcffe”然后,您可以像通常使用Objective-C类一样实例化它。@DaxeshNagar下面是我在项目中如何使用它的一个示例:
SideMenuSettings*_settings=[[SideMenuSettings alloc]init];[\u设置setPresentationStyle:SideMenuUpPresentationStyle.menuSlideIn];SideMenuPresentationStyle*_style=_settings.presentationStyle_style.presentingScaleFactor=0.9;SideMenuNavigationController*\u sideMenu=[[SideMenuNavigationController alloc]initWithRootViewController:sectionsView设置:\u设置];[_sidemenusetleftside:YES];[[SideMenuManager defaultManager]设置LeftMenuNavigationController:_sideMenu]