iOS UI进阶-6.0 手势
2015-12-20 10:20
387 查看
给每个页面添加手势,只需要统一设置不是根控制器的页面,都增加手势。需要自定义导航控制器
1.继承代理
2.设置代理
3.实现代理
在开发过程中,经常会用到,需要关闭某个页面的手势返回功能。
参考网站:http://blog.csdn.net/jasonblog/article/details/28282147
1.继承代理
@interface BSNavigationController ()<UIGestureRecognizerDelegate>
2.设置代理
- (void)viewDidLoad { [super viewDidLoad]; // 设置pop手势代理 self.interactivePopGestureRecognizer.delegate = self; }
3.实现代理
#pragma mark - <UIGestureRecognizerDelegate> /** * push进来的控制器大于1个,手势有效 */ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ return self.viewControllers.count > 1; }
在开发过程中,经常会用到,需要关闭某个页面的手势返回功能。
// 禁用返回手势 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 禁用 返回手势 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } } // 开启手势 - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // 开启手势 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } } // 导航栏返回 - (void)blackBtnClick { // 开启手势,有时只在(void)viewWillDisappear:(BOOL)animated开启,该根栏目下所有的手势都会失效 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } [self.navigationController popToRootViewControllerAnimated:YES]; }
参考网站:http://blog.csdn.net/jasonblog/article/details/28282147
相关文章推荐
- 初识Power Builder9.0
- MVC jsonModelBuilder
- UE编辑技巧
- hdu5568 sequence2 dp+大数
- 如何在Autolayout的模式下动态设置 UITableView的 tableHeader 的高度
- UVAlive2531 The K-League(最大流)
- UI交互设计的网站
- 动态修改UINavigationBar的背景色
- Leetcode: Implement Queue using Stacks
- IPtables中SNAT和MASQUERADE的区别
- QuickContactBadge 自定义获取联系人
- ERROR: No query specified
- UILabel,UIButton,UITextField的简单使用
- UIUITableView 分组标题
- UIView中的坐标转换
- 改变UITableView的headerView、footerView背景颜色
- Android布局问题: No resource found that matches the given name (at 'layout_above' with value @id/tv)
- UESTC 653 扫雷 模拟
- UIScrollView自动布局
- DSOJ Level-order sequence with degree(森林的带度数层次遍历序列)