Ios左右菜单PPRevealSideviewController使用的一些心得
来源:互联网 发布:thug life 视频软件 编辑:程序博客网 时间:2024/05/16 03:03
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这个文件夹拖到工程中来,在工程启动入口那儿:
- (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;}当然,你先要定义一个 _revealSideViewController 并先实现它。
在跳转到我们的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 swift下使用PPRevealSideViewController
- Sidebar 左右菜单的使用
- iOS多线程的一些使用心得
- ios左右菜单
- ios左右菜单2
- SlidingMenu的使用之一(左右菜单)
- 左右滑动菜单,模仿 ios智慧无锡 上的左右滑动菜单
- 使用 7230的一些心得
- TreeView使用的一些心得
- 使用JTAG的一些心得
- eval解析JSON中的注意点
- socket通信:C#实现Socket通信
- linux进程间传递描述符
- DAG单源最短路径
- Invalid ActiveMQ Schema Name Space
- Ios左右菜单PPRevealSideviewController使用的一些心得
- 利用OpenCV计算并绘制灰度直方图 (转载)
- 使用AF_INET实现UDP点对点通信示例
- Windows2003服务器安装及设置教程——MySQL安全篇
- 关于Android的Crash
- 解决XP 系统 .Net Framework 4安装时出现严重错误 (0x80070643)
- DB2日期时间型数据类型介绍
- AS3 的正则又有一些不一样的用法
- if else wile if...elseif..else for循环 do..while