你需要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 设置为根视图控制器,例如 Add #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"];
}