【发布时间】:2016-04-06 05:29:33
【问题描述】:
我已经在我的应用程序中实现了 iOS 滑动菜单导航控制器,并且之前它工作正常。但不知何故,现在它的左菜单视图控制器正在黑屏。请建议是否有人遇到此问题。下面的代码我在 Appdelegate.m didFinishLaunchingWithOptions 中提到过。
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
self.navigationController = (UINavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"navBar"];
self.landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"FirstViewController"];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
LeftMenuViewController *leftMenu = (LeftMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
self.landingScreen = [SlideNavigationController sharedInstance];
self.landingScreen.leftMenu = leftMenu;
// Creating a custom bar button for right menu
[[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);
}];
【问题讨论】:
-
你给故事板ID提供了标识符吗?
-
确保你的 self.navigationController 不是 nil。
-
是的,我已经提到过。这比昨天晚上更早工作正常。我昨天刚刚用 //**NSLog 替换了 NSLog 并将构建发送到客户端,它的显示就像图像一样。今天我再次将 //**NSLog 与 NSLog 互换。但它仍然显示上述内容。
-
没有。我已经提到过 self.navigationController = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"navBar"];并且这个导航控制器与视图控制器相连
-
当我在情节提要中提到了左菜单视图控制器的错误标识符时。在给出正确的标识符后,它在编译时显示错误,其构建成功,如上图。
标签: ios objective-c uinavigationcontroller navigation-drawer