navigationcontroller手势翻页和navigationbar
2015-06-18 09:06
267 查看
一. 系统导航默认手势
#import "CBNavigationController.h" //手势返回 @interface CBNavigationController ()<UIGestureRecognizerDelegate, UINavigationControllerDelegate> @end @implementation CBNavigationController - (void)viewDidLoad { [super viewDidLoad]; __weak CBNavigationController *weakSelf = self; if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.interactivePopGestureRecognizer.delegate = weakSelf; self.delegate = weakSelf; } } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } // Hijack the push method to disable the gesture //推进控制器 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = NO; [super pushViewController:viewController animated:animated]; } //推出控制器 - (UIViewController *)popViewControllerAnimated:(BOOL)animated { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = YES; return [super popViewControllerAnimated:animated]; } #pragma mark UINavigationControllerDelegate //已经显示了控制器 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animate { //注意:这里当导航控制器只有一个viewcontroller的时候不能可以手势,否则奔溃 if(self.viewControllers.count > 1) { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = YES; } else { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = NO; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
二. 导航栏的barStyle 和 translucent
iOS7之后由于navigationBar.translucent默认是YES,坐标零点默认在(0,0)点 当不透明的时候,零点坐标在(0,64);如果你想设置成透明的,而且还要零点从(0,64)开始,那就添加:self.edgesForExtendedLayout = UIRectEdgeNone;translucent = NO, 零点从(0,64)开始, 如果想要零点从(0,0)点开始, 只需要设置: self.extendedLayoutIncludesOpaqueBars = YES;
@property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars NS_AVAILABLE_IOS(7_0); // Defaults to NO, but bars are translucent by default on 7_0.
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES
相关文章推荐
- 平衡车跌倒 雷军能扶起这个阿斗吗?
- Ogre基础教程5:有缓冲输入
- 用位运算实现四则运算之加减乘除
- 谈谈iOS中粘性动画以及果冻效果的实现
- C++ Primer Plus学习笔记三(第四章)
- android端手机测试体系 (转)
- 获取硬件资源
- asp 调用 vb(activex dll) ,参数传递(传引用)需要注意
- easyUI datagrid 查询方法
- Android中的Handler01
- SVN老是清理失败,显示清理乱码
- SVN老是清理失败,显示清理乱码
- linux ddns client ddclient
- oracle 在操作blob该字段是否会产生很多redo
- asp <----> vb(com,dll) <---> c 来回的调用,生命在于折腾
- 社説 20150618 18歳選挙権 若者の政治参加を促進したい
- HTTP/1.1 100 Continue - I 服了 You
- 升级到OpenCms 9.5.1后原来的xmlpage类型文档不能操作解决
- 社説 20150618 党首討論 岡田氏は米艦防護を拒むのか
- 报错 No resource identifier found for attribute '****' in package '***.***'解决办法