我正在使用库SWRevealViewController进行前视图和后视图,它可以工作。 问题是,当我点击菜单按钮时,导航栏下方的后视图si和前视图向右移动。
可以锁定前视图并查看导航栏顶部的菜单吗?
我的代码:
在Appdelegate中:
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
SplashScreenViewController *splashScreenViewController = (SplashScreenViewController *)[storyboard instantiateViewControllerWithIdentifier:@"splash"];
UINavigationController *navControllerFront = [[UINavigationController alloc]initWithRootViewController:splashScreenViewController];
MenuNavigationViewController *menuViewController = (MenuNavigationViewController *)[storyboard instantiateViewControllerWithIdentifier:@"menu"];
UINavigationController *navControllerRear = [[UINavigationController alloc]initWithRootViewController:menuViewController];
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:navControllerRear frontViewController:navControllerFront];
revealController.delegate = self;
self.viewController = revealController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
FrontView文件(不是启动画面):
SWRevealViewController *revealController = [self revealViewController];
[revealController panGestureRecognizer];
[revealController tapGestureRecognizer];
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setNavigationBarHidden:NO animated:YES];
UIBarButtonItem *revealButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu.png"] style:UIBarButtonItemStylePlain target:revealController action:@selector(revealToggle:)];
revealButtonItem.image = [revealButtonItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationItem.leftBarButtonItem = revealButtonItem;
如何解决问题?
非常感谢
编辑:我已在“didFinishLaunchingWithOptions”方法中使用此代码解决了
SWRevealViewController *revealViewController = (SWRevealViewController *)self.window.rootViewController;
UINavigationController* navController = (UINavigationController*)revealViewController.frontViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
NewSplashScreenViewController *start = (NewSplashScreenViewController *)[storyboard instantiateViewControllerWithIdentifier:@"splashnew"];
[navController setViewControllers: @[start] animated: YES];
[revealViewController setFrontViewController:navController];
[revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
答案 0 :(得分:0)
我对这个问题没有明确的答案,但我需要在我的项目中实现相同的功能。
SWRevealController的作者坚持一种实现此功能的方法。我还在努力。
链接是:https://github.com/John-Lluch/SWRevealViewController/issues/312
我猜人们仍然无法弄清楚到底是怎么做的。