大家好我尝试使用https://github.com/aryaxt/iOS-Slide-Menu作为我的一个viewcontroller的幻灯片菜单。我读到滑动菜单中的文档,这里是我的AppDelegate类,didFinishLaunchingWithOptions方法:使用iOS-Slide-Menu的iphone幻灯片菜单
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[StyleKit setupAppearance];
ListViewController *controller = [ListViewController new];
_navigationController = [[UINavigationController alloc]
initWithRootViewController:controller];
RightViewController *rightMenu = [RightViewController new];
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = _navigationController;
[self.window makeKeyAndVisible];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Closed %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Opened %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Revealed %@", menu);
}];
return YES;
}
我要显示在“ListViewController”滑动菜单,以便为文档说我实现了我的头文件是这样的:
//
// ListViewController.h
#import <UIKit/UIKit.h>
#import "SlideNavigationController.h"
@interface ListViewController :
UIViewController<SlideNavigationControllerDelegate>
@end
// ListViewController.m
//Some code...
- (void)setupActions {
[self.listView.tableHeaderView.followButton addTarget:self"
action:@selector(didTapFollowButton:)
forControlEvents:UIControlEventTouchUpInside];
[self.fakeNavigationController.menuButton addTarget:
[SlideNavigationController sharedInstance]
action:@selector(toggleRightMenu)
forControlEvents:UIControlEventTouchUpInside];
}
- (BOOL)slideNavigationControllerShouldDisplayLeftMenu
{
return NO;
}
- (BOOL)slideNavigationControllerShouldDisplayRightMenu
{
return YES;
}
但是,当我启动应用程序时,我得到这个错误: SlideNavigationController尚未初始化。将其中一个放入故事板,或者用代码初始化一个。
请等待你的帮助,感谢小号:)
你在你的故事板添加视图控制器?如果没有,然后添加它,并将其设置为初始视图控制器 –
我没有故事板... @ ravi.p – phantom