首页 > 移动平台 > 详细

iOS UI进阶-6.0 手势

时间:2015-12-20 11:33:17      阅读:295      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!