从PPRevealSideViewController中的导航栏下方开始滑动视图

时间:2013-09-25 13:26:46

标签: ios uinavigationcontroller

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

问题是右侧视图位于navigationBar下方,如图中红色椭圆所示。它不是从极端的顶端开始的。什么是修复?

左侧和右侧viewControllers有navigationBar。

代码:

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];

enter image description here

1 个答案:

答案 0 :(得分: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添加到主推视图控制器中self.window

例如,你可以实现这个

在你HomeViewcontroller push rightViewcontroller你需要再次将rightViewcontrollre作为像添加#import <QuartzCore/QuartzCore.h>这样的rootviewcontroller: -

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"];


}

如果你想支持你主页视图控制器使用这个代码: -

-(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"];


}