[IOS 视图布局]左右菜单PPRevealSideviewController
来源:互联网 发布:js confirm 套for循环 编辑:程序博客网 时间:2024/06/05 01:49
http://blog.csdn.net/qjlhlh/article/details/8204563
PRevealSideviewController是一个左右移动布局,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这个文件夹拖到工程中来,在工程启动入口那儿:
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- MainViewController *main = [[MainViewController alloc] init];//你自己的中间controller
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main];
- _revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];
- _revealSideViewController.delegate = self;
- self.window.rootViewController = _revealSideViewController;
- PP_RELEASE(main);
- PP_RELEASE(nav);
- self.window.backgroundColor = [UIColor whiteColor];
- [self.window makeKeyAndVisible];
- return YES;
- }
在跳转到我们的mainViewController后,我们需要先preLoad,预加载你的左、右viewContrller 这样用手势左右划动的时候就能跳到左右菜单了
- - (void) preloadView {
- LeftViewController *left = [[[LeftViewController alloc] init] autorelease];
- [self.revealSideViewController preloadViewController:left
- forSide:PPRevealSideDirectionLeft
- withOffset:_offset];
- RightViewController *right = [[[RightViewController alloc] init] autorelease];
- [self.revealSideViewController preloadViewController:right
- forSide:PPRevealSideDirectionRight
- withOffset:_offset];
- }
- - (void) viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadView) object:nil];
- [self performSelector:@selector(preloadView) withObject:nil afterDelay:0.3];
- }
其它常用操作:
1 跳转到一个菜单
- LeftViewController *left = [[LeftViewController alloc] init];
- [self.revealSideViewController pushViewController:left onDirection:PPRevealSideDirectionLeft withOffset:_offset animated:_animated];
- PP_RELEASE(left);
2 返回
- [self.revealSideViewController pushOldViewControllerOnDirection:PPRevealSideDirectionLeft animated:YES];
3。在左/右边菜单跳转到一个新的页面
- SecondViewController *c = [[SecondViewController alloc] init];
- UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:c];
- [self.revealSideViewController popViewControllerWithNewCenterController:n animated:YES];
- PP_RELEASE(c);
- PP_RELEASE(n);
4 用第3步中进行跳转后的新页面,还能划动到右边的菜单,有时候我们只想要一个左边菜单,要么上边的,可以用这个方法删除其它方向的:
- [self.revealSideViewController unloadViewControllerForSide:PPRevealSideDirectionRight];//删掉右边的viewController
具体的菜单逻辑跟据自己项目中来吧,方法差不多就这些了,在PPRevealSideviewController的demo里写得比较清楚的,可以仔细研究一下。
- [IOS 视图布局]左右菜单PPRevealSideviewController
- iOS左右菜单PPRevealSideviewController
- Ios左右菜单PPRevealSideviewController使用的一些心得
- Ios左右菜单PPRevealSideviewController使用的一些心得
- ios左右菜单PPRevealSideviewController使用的一些心得
- Ios左右菜单PPRevealSideviewController使用的一些心得
- Ios左右菜单PPRevealSideviewController使用的一些心得
- Ios左右菜单PPRevealSideviewController使用的一些心得
- ios左右菜单
- ios左右菜单2
- IOS开发 左右弹出菜单视图 菜鸟纯代码实现思路
- iOS 视图左右晃动动画
- ios swift下使用PPRevealSideViewController
- 【IOS动画】视图左右抖动动画效果
- 【ios 汇总 - UI 视图布局 】
- freemark和bootstrap中页面布局,页签,左右菜单
- Android DrawerLayout+NavigationView布局实现左右两边侧滑菜单
- 左右菜单
- linux hook
- avr_compiler.h
- html中几种常用样式
- 全零网络ip地址0.0.0.0表示意义详解
- 时间戳转时间
- [IOS 视图布局]左右菜单PPRevealSideviewController
- UIView的layoutSubviews和drawRect方法何时调用
- jQuery Ajax 实例 全解析
- Hibernate 4.0 新特性之 Service(Registry)
- DMAの数据传输
- Eclipse中10个最有用的快捷键组合
- xml基础知识(一)
- 异步解析xml读新浪新闻作业总结
- ATxmega128A1のDMA驱动程序