我在nib文件中添加幻灯片导航时遇到问题。 请帮帮我
我有一个例子,但它的故事板,我希望它在笔尖中使用,所以我可以在左侧打开一个菜单表格
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
// Creating a custom bar button for right menu
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[button setImage:[UIImage imageNamed:@"gear"] forState:UIControlStateNormal];
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
[SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem;
SlideNavigationController *nav = [[SlideNavigationController alloc] initWithRootViewController:viewCon];
nav.navigationBarHidden=YES;
self.window.rootViewController=nav;
[self.window makeKeyAndVisible];
答案 0 :(得分:1)
我发现这是nib的非常简洁的解决方案,我将它用于我自己的项目。你可以看一下: https://maniacdev.com/2013/08/open-source-component-for-making-a-nice-ios-7-control-center-style-animated-side-bar-menu
答案 1 :(得分:0)
创建您的LeftMenuViewController
Xib以及实现和头文件。最后你应该提交这些文件:
LeftMenuViewController.h
LeftMenuViewController.m
LeftMenuViewController..xib
并替换
行LeftMenuViewController *leftMenu = (LeftMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
用这个 - 从xib加载控制器
LeftMenuViewController *sm = [[A1SideMenuViewController alloc]initWithNibName:@"LeftMenuViewController" bundle:nil];