zoukankan      html  css  js  c++  java
  • PPRevealSideViewController

    PPRevealSideviewController是一个左右移动布局,ios左右菜单的一个东西,功能非常强大,使用起来也很方便。

    研究了两天,说不上全会用了,但会一些,把一些关键点记下来,希望能帮助到您。

    下载PPRevealSideviewController,下载地址

    下载下来后有个叫PPRevealSideViewController的项目,打开就是整个demo,demo写得非常强大,这儿主要解释下各个开关的作用。

    先看一下图:


         

    Animated:是否有动画

    Shadow:中间界面阴影

    Resize:左边的tableView菜单是否有一个下拉条

    Bounce:是否有一点点弹跳,当你没有初始化left/right/top/down的controller,你向left/right/top/down方向拉的时候,虽然不能跳转界面,但是有个弹跳的一个小效果

    Close Full:是否能从左直接拉到右边

    Offset:偏移量

    Opened:可以看到opened的开关上面有个NavBar和Content,这儿的开关是指,是否可以用手势Opend这个页面,在哪儿的手势呢?一个是NavBar上的手势,另一个当然是content的了。

    Closed:同Opened

    Tap closed:是否可以点击进行关闭页面,上面的opened和Closed指的是手势,这儿指的是点击。

    Keep offset:这个我暂时也不清楚 ^_^

    其它带字的比较好理解了,可以自己试一下。


    说下大概用法吧:

    下载下来后,把PPRevealSideviewController这个文件夹拖到工程中来,在工程启动入口那儿:

    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
    2. {  
    3.     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];  
    4.       
    5.     MainViewController *main = [[MainViewController alloc] init];//你自己的中间controller  
    6.     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main];  
    7.     _revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];  
    8.     _revealSideViewController.delegate = self;  
    9.     self.window.rootViewController = _revealSideViewController;  
    10.       
    11.     PP_RELEASE(main);  
    12.     PP_RELEASE(nav);  
    13.       
    14.     self.window.backgroundColor = [UIColor whiteColor];  
    15.     [self.window makeKeyAndVisible];  
    16.     return YES;  
    17.   
    18. }  

    当然,你先要定义一个 _revealSideViewController 并先实现它。

    在跳转到我们的mainViewController后,我们需要先preLoad,预加载你的左、右viewContrller 这样用手势左右划动的时候就能跳到左右菜单了

    1. - (void) preloadView {  
    2.     LeftViewController *left = [[[LeftViewController alloc] init] autorelease];  
    3.     [self.revealSideViewController preloadViewController:left  
    4.                                                  forSide:PPRevealSideDirectionLeft  
    5.                                               withOffset:_offset];  
    6.       
    7.     RightViewController *right = [[[RightViewController alloc] init] autorelease];  
    8.     [self.revealSideViewController preloadViewController:right  
    9.                                                  forSide:PPRevealSideDirectionRight  
    10.                                               withOffset:_offset];  
    11. }  
    12.   
    13. - (void) viewDidAppear:(BOOL)animated {  
    14.     [super viewDidAppear:animated];  
    15.     [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadView) object:nil];  
    16.     [self performSelector:@selector(preloadView) withObject:nil afterDelay:0.3];  
    17. }  


    其它常用操作:

    1 跳转到一个菜单

    1. LeftViewController *left = [[LeftViewController alloc] init];  
    2. [self.revealSideViewController pushViewController:left onDirection:PPRevealSideDirectionLeft withOffset:_offset animated:_animated];  
    3. PP_RELEASE(left);  

    2 返回

    1. [self.revealSideViewController pushOldViewControllerOnDirection:PPRevealSideDirectionLeft animated:YES];  


    3。在左/右边菜单跳转到一个新的页面

    1. SecondViewController *c = [[SecondViewController alloc] init];  
    2. UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:c];  
    3. [self.revealSideViewController popViewControllerWithNewCenterController:n animated:YES];  
    4. PP_RELEASE(c);  
    5. PP_RELEASE(n);  

     4  用第3步中进行跳转后的新页面,还能划动到右边的菜单,有时候我们只想要一个左边菜单,要么上边的,可以用这个方法删除其它方向的:

    1. [self.revealSideViewController unloadViewControllerForSide:PPRevealSideDirectionRight];//删掉右边的viewController  

    具体的菜单逻辑跟据自己项目中来吧,方法差不多就这些了,在PPRevealSideviewController的demo里写得比较清楚的,可以仔细研究一下。


    我自己仿照“时光流”这个应用做了个左边菜单:





  • 相关阅读:
    表示数值的字符串(C++描述)
    单链表是否有环及环入口点
    医院信息运维系统-信息科专用运维系统
    c# List 按类的指定字段排序
    运维系统说明
    更新库下载
    mysql数据库备份
    网络编程基础
    面向对象和过程,一样的价格,不一样的口味
    模块的导入顺序细节
  • 原文地址:https://www.cnblogs.com/wangzhendong/p/4033284.html
Copyright © 2011-2022 走看看