你需要在你的项目中隐含 PPRevealSlideViewController 像这样:-
LoginPageViewController *login = [[LoginPageViewController alloc]initWithNibName:@"LoginPageView" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:login];
_revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];
[self.window setRootViewController:_revealSideViewController];
我认为在你的代码中你添加了两个导航控制器你只需要添加一个导航控制器而你将PPRevealSideViewController添加到主pushviewcontroller到self.window
例如,您可以做到这一点
在你HomeViewcontroller push rightViewcontroller你需要再次将Viewcontrollre作为rootviewcontroller添加#import <QuartzCore/QuartzCore.h>:-
ObjAppDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate]; //创建appdelegate对象
-(IBAction)ActionPushrightViewcontroller
{
rightViewcontroller *login = [[rightViewcontroller alloc]initWithNibName:@"rightViewcontroller" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:login];
_revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];
[ObjAppDelegate.window setRootViewController:_revealSideViewController];
UIInterfaceOrientation interfaceOrientation = _revealSideViewController.interfaceOrientation;
NSString *subtypeDirection;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
subtypeDirection = kCATransitionFromTop;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
subtypeDirection = kCATransitionFromBottom;
}
else {
subtypeDirection = kCATransitionFromRight;
}
[ObjAppDelegate.window setRootViewController:_revealSideViewController];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:subtypeDirection];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[ObjAppDelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];
}
如果你想支持你的 Home 视图控制器,请使用以下代码:-
-(IBAction)ActionPopHomeviewcontroller
{
Homeviewcontroller *Home = [[Homeviewcontroller alloc]initWithNibName:@"Homeviewcontroller" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:Home];
UIInterfaceOrientation interfaceOrientation = viewController.interfaceOrientation;
NSString *subtypeDirection;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
subtypeDirection = kCATransitionFromTop;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
subtypeDirection = kCATransitionFromBottom;
}
else {
subtypeDirection = kCATransitionFromLeft;
}
[ObjAppDelegate.window setRootViewController:nav];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:subtypeDirection];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[ObjAppDelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];
}