0

在我的应用程序中,我使用的是 PPRevealSlideViewController。

问题是右侧视图位于导航栏下方,如图中红色椭圆所示。它不是从极端顶部开始的。解决办法是什么?

左右侧视图控制器都有导航栏。

代码 :

MainController main = [[MainController alloc] initWithNibName:@"MainController" bundle:nil];

UINavigationController *navMainController = [[UINavigationController alloc] initWithRootViewController:main];

PPRevealSideViewController *revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:navMainController];

revealSideViewController.delegate = main;

[self.navController pushViewController:revealSideViewController animated:YES];

[main release];

在此处输入图像描述

4

1 回答 1

1

你需要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"];


}
于 2013-09-25T13:46:48.383 回答