码迷,mamicode.com
首页 > 移动开发 > 详细

iOS UI进阶-6.0 手势

时间:2015-12-20 11:35:33      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

在开发过程中,经常会用到,需要关闭某个页面的手势返回功能。

// 禁用返回手势
- (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

 

iOS UI进阶-6.0 手势

标签:

原文地址:http://www.cnblogs.com/jys509/p/5060327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!